Jquery .load function and adding and removing classes

572 Views Asked by At

I'm trying to add custom css animations to some images, but I just can't seem to get my head wrapped around the solution. My code is found below. On window load I would like the class 'animated shake' to be added to the element with the id "blue". After the animation occurs, remove the animation class.

$(window).load(function(){
      $("#blue").addClass('animated shake').0ne('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend',function(){
          $(this).removeClass('animated shake');
    });
};
2

There are 2 best solutions below

0
Brian On BEST ANSWER

Do you not use the console to debug? You have a typo and missing parenthases that would have shown if you did.

$(window).load(function(){ 
    $("#blue").addClass('animated shake')
    .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend',function(){
        $(this).removeClass('animated shake'); 
    }); 
});
3
jfriend00 On

You appear to have a typo:

.0ne() should be .one()