尊敬的专家,
我有一个问题。我是 Jquery 的新手,我正在尝试根据下面给出的示例代码使用 div 动画。发生的情况是,当将鼠标多次悬停在 div 上时,操作会自行复制并导致我想以某种方式避免的可用性行为。有没有办法让功能检查鼠标行为,例如 div 在给定时间内悬停以避免不必要的多次激活? 我希望我解释得足够好。
感谢您的输入。
$(document).ready(function() {
$("#expand_smoke").hover(
//on mouseover
function() {
$(this).animate({
height: '+=125' //adds 125px
}, 'slow' //sets animation speed to slow
);
},
//on mouseout
function() {
$(this).stop()
$(this).animate({
height: '60' //changes back to 60px
}, 'slow'
);
}
);
});
最佳答案
你为什么不这样做呢?
$("#expand_smoke").hover(
function() {
$(this).stop().animate({ height: '200' }, 'slow');
},
function() {
$(this).stop().animate({ height: '60' }, 'slow');
}
);
关于jquery - 在悬停时停止不必要的 div 重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12698783/