I'm having trouble correcting this code, since I have very little experience with jQuery:
$("#msg-button").click(function() {
$("#msg_alert").removeClass("msg_stop").addClass("msg_play");
setTimeout(function() {
$("#msg_alert").removeClass("msg_play").addClass("msg_stop")
}, 2000);
});
The thing is, when I use the "incorrect code," the effect I'm aiming for works.
This script is my workaround for restarting a CSS3 animation. Whenever the user clicks id #button
, id #msg_alert
is displayed by playing out the animation in class .msg_play
. The animation lasts for two seconds; hence, there is a two-second delay for the next part of the script, which basically switches id#msg_alert back to class.msg_stop.
I tried following the error alert returned by jsFiddle, but after changing the code accordingly, the script stops working. (Although actually, when I run jslint again after correcting the first two errors, I get more errors, so I keep correcting them until jsFiddle tells me that my code is invalid.