gpt4 book ai didi

jquery 动画问题

转载 作者:行者123 更新时间:2023-12-01 04:30:50 25 4
gpt4 key购买 nike

jquery代码

$(function(){
$('#switcher1').click(function(){
$(this).stop().animate({left:'35px'},800);
});
});

大家好,这段代码将 #switcher1 向右滑动 35px。我有问题,如何才能使 #switcher1 再单击一次滑回到原始位置?

最佳答案

使用toggle :

$('#switcher1').toggle(function() {
$(this).stop().animate({left:'35px'},800);
}, function() {
$(this).stop().animate({left:'0px'},800);
});

关于jquery 动画问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2649797/

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