Posted By

kbrown on 06/23/11


Tagged

class image jquery fade animate


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

spee66


jQuery Fade/Animate an image in a class


 / Published in: jQuery
 

  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
Posted By: Some0ne on June 23, 2011

Chaining:

$('.projectHolder img').hover(function() { $(this).stop().animate({opacity:0.5},400); } ,function() { $(this).animate({opacity:1},400); });

You need to login to post a comment.