I'm trying to create an animation for all the divs called switch in the html. Imagine for example the typical iphone Cocoa switch. The animation works Ok, But it's only applied to the first component not for all of them, althou开发者_运维问答gh they are all called switch
Any suggestion?
Thanks!!
Well change your handler:
$('.photoItemWhite').mouseover(function() {
$(this).animate({top: '-25px'}, 500);
});
When jQuery calls your event handler, it will make sure that this
refers to the element for which the handler is being invoked.
$(".photoItemWhite").mouseover(function(){ $(this).animate({ top: "-25px" }, 500 ); });
use this keyword
精彩评论