gpt4 book ai didi

javascript - 鼠标悬停时停止动画

转载 作者:行者123 更新时间:2023-12-02 20:19:15 26 4
gpt4 key购买 nike

我的鼠标悬停功能可以对对象的宽度进行动画处理,但当它到达目的地时,它会来回移动 2 或 3 个像素。有没有办法解决这个问题。

$(this).mousover(function() {
$('myselector').animate( {'width': 200} );
// this is all have for my animation but it moves alot
});

最佳答案

如果您想在 mouseover 上将宽度设置为 200 像素,然后在 mouseout 上将宽度设置为 200 像素(例如:100 px),这会有所帮助:

$(this).mouseover(function() {
$('myselector').stop().animate( {'width': 200} );
});

$(this).mouseout(function() {
$('myselector').stop().animate( {'width': 100} );
});

关于javascript - 鼠标悬停时停止动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5815866/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com