Pata Posted August 10, 2020 Share Posted August 10, 2020 I want to animate an element and its child on a forEach. I don't know how to point to that element on my GSAP line. Many thanks in advance, elements.forEach((e) => { e.addEventListener('mouseover', function() { gsap.to(e, {y: 100}) gsap.to(**CHILD ELEMENT OF e**, {y: -100}) }) }) Link to comment Share on other sites More sharing options...
PointC Posted August 10, 2020 Share Posted August 10, 2020 let child = e.querySelector("yourChildTarget"); gsap.to(child, {y: -100}) 2 Link to comment Share on other sites More sharing options...
Pata Posted August 10, 2020 Author Share Posted August 10, 2020 4 minutes ago, PointC said: let child = e.querySelector("yourChildTarget"); gsap.to(child, {y: -100}) Thanks, now that I see the solution it seems so obvious. Link to comment Share on other sites More sharing options...
ZachSaucier Posted August 10, 2020 Share Posted August 10, 2020 Side note: e typically signifies an event. I might name it elem or something. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now