开发者

JQuery onmouseover only affecting to one component

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜