Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Cristhian Cordero
4,871 Pointsanimating text in javascript
Hi, I'm relative new using javascript and I'm wondering how can I do an animation like this using an array of words and changing the speed of the highligted word
https://i.stack.imgur.com/K8j6j.gif
thanks
1 Answer
Steven Parker
243,658 Points
There are many different approaches that would all work.
But one reasonably simple one that comes to mind would be to establish a CSS class that causes the highlighting to appear, and then use the JavaScript setInterval function to sequentially set and remove the CSS class from the elements of your word list. One of the arguments to setInterval is the amount of time between changes, so that would control the speed of the movement.
Cristhian Cordero
4,871 PointsCristhian Cordero
4,871 Pointsthanks Steven, until now I have this http://codepen.io/CristJian/pen/ObKRJy but I dont know how to make more than 1 column if I put more words like the example :(