jQuery CSS animations with addClass and removeClass
So, I have now made jQuery Ajax code that checks that the username and password are correct. But instead of just displaying a error message, I’d like to shake the element as well.
That kind of shake that wordpress has. Go to wordpress.com/wp-login.php and fill there some random info and the element shakes.
That shake can be done by Animate.css.
What’s the problem then?
When the login fails, jQuery makes this.
But because the shake element has CSS Animations that run only once, we won’t be needing the CSS shake class after it shaked the element.
So I tried:
But that happens all too quickly.
So I tried again:
Still not play the animation and then remove the class
.shake from the
.element. If the user enters wrong details more then once then shake won’t work.
You can play with the fiddle here.
Goal is to be able to shake the element more then once by clicking the Shake button.
You could use the following to remove the class when the animation completes.