如果鼠标结束,我在一些帮助下制作了一个Text来移动文本。我的问题是我不能分开这些动作。如果我超过任何Box,那么所有Box都会产生效果。
$(document).ready(function(){
$('.up-down').mouseover(function(){
$('.default').stop().animate({
height: 200
}, 200);
}).mouseout(function(){
$('.default').stop().animate({
height: 240
}, 200)
})
});
答案 0 :(得分:2)
您必须选择当前悬停元素的子元素:
$(document).ready(function(){
$('.up-down').mouseover(function(){
$(this).children('.default').stop().animate({
height: 200
}, 200);
}).mouseout(function(){
$(this).children('.default').stop().animate({
height: 240
}, 200)
})
});
答案 1 :(得分:0)
因为你正在使用$('.default')
,所以任何具有类默认值的元素都将被采取行动。
如果.default在.up-down内,你可以使用
$(this).find('.default')
......它只会对正确的元素起作用。