Share Posted May 31, 2019 What am I doing wrong here. On mouse hover it should enlarge the text hovered. On mouseleave it should scale back. See the Pen ZNmJEz by anon (@anon) on CodePen Link to comment Share on other sites More sharing options...
Share Posted May 31, 2019 There were several problems. First, you were using document.getElementsByClassName(".st1") which returns a NodeList (like an Array), but you were treating it like it'd return a single element (by appending .addEventListener(....)). You can't addEventListener() to a NodeList/Array. Also, you used the wrong selector text. It should simply be "st1", not ".st1" because you're using getElementsByClassName(). I'd recommend switching to document.querySelectorAll() which is more flexible and you can use that selector text (".st1"). You had logic that'd cause things to grow when the mouse LEAVES them (instead of when it rolls over them). I assume that behavior was inverted, based on what you said in your question. I wasn't sure if you wanted each piece to animate independently, but here's a fork: See the Pen 07568569cbe81411ec128eb0a9f542c4?editors=0010 by GreenSock (@GreenSock) on CodePen Does that help? 3 Link to comment Share on other sites More sharing options...
Author Share Posted May 31, 2019 Love your explanation. thanks 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