【发布时间】:2011-07-27 23:46:04
【问题描述】:
没有做太多 jquery 并遇到了问题。我想将所有 div 的悬停事件与类 .social-tile 绑定。我是这样做的:
$(function(){
var social_default = $('.social-tile').css('margin-right');
$('.social-tile').each(function(){
$(this).hover(function(){
$(this).animate({
'margin-right': '0px'
},500);
},function(){
$(this).animate({
'margin-right': social_default
},500);
});
});
});
当我将鼠标悬停在一个元素上时,所有 div 的动画都会被触发,它们会同时移动。我只想为我悬停的特定元素设置动画。
这里可能有一个非常简单的解决方法, 谢谢。
【问题讨论】:
标签: jquery hover jquery-animate each