I’m trying to use jQuery’s toggleClass for a news ticker type thing, and it works for the most part, but intermitantly it doesn’t animate. Here is the code I have:
$(document).ready(function() {
// ...other jQuery code
setInterval('$("#stat-slider").toggleClass("all-time", 1000);', 10000);
}
The first time the page loads, it flicks between the two states quickly, then runs as normal, except that sometimes it doesn’t animate. Can anyone see anything that would cause this?
Many thanks.
P.S. Happens in FireFox and Internet Explorer 9
I believe it doesn’t work correctly because of the number you entered in toggleClass.
Try it without number like this:
setInterval('$("#stat-slider").toggleClass("all-time");', 10000);Hope it helps.