开发者

JQuery onmouseover only affecting to one component

开发者 https://www.devze.com 2023-02-12 08:25 出处:网络
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 componen

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

精彩评论

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