Gsap doesn't work with CLASS or ID made in js?

gsap works when the class or id is created in html, but not in javascript. Is there any method to make the class or id work with gsap?


I would try to add the element to the DOM before you use gsap on it.


Not workin

You should throw up a codepen when its not ‘workin’ (sic) so we can easily debug for you.:slight_smile:

I assume you have moved the append as instructed by @Thallius so that it is before you call it with the gsap routine?

I also assume you have defined body so your code should look roughly like this.

const TheSecondParent = document.createElement("div");
const body = document.querySelector('body');
gsap.from(".SecondParent", {duration: 1, y: "-100%", ease: "bounce" });

Caveat, I know nothing about gsap and very little JS :slight_smile:


I got it, I didn’t know you had to put body.append above gsap.

Without it, you would be calling GSAP that isn’t a part of the DOM. GSAP can’t find something that doesn’t exist.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.