jQuery Fade/Animate an image in a class


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $('.projectHolder').hover(
  2.  
  3. function() { //This is the hover in function
  4.  
  5. $("img", this).stop(); //Stops any animation being done on the button
  6.  
  7. $("img", this).css({opacity:1}); //Changes the opacity back to not if not already
  8.  
  9. $("img", this).animate({opacity:0.5},400); //Now animates the opacity to the user defined value
  10.  
  11. },
  12.  
  13. function() { //This is the hover out function
  14.  
  15. $("img", this).animate({opacity:1},400); //Animates the opacity back to 1
  16.  
  17. }
  18.  
  19. )

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.