脚本会动画但不会切换

script will animate but not toggle

我是运行一个应该上下切换的脚本

$(document).ready(function(){
$('#movedown').toggle(function() {
$(".menu2").animate({top: '-=1512px'}, 500);
}, function() {
$(".menu2").animate({top: '+=1512px'}, 500);
});
});

不会切换http://toddheymandirector.com/index_mobile99.html but if I replace toggle with click it will slide down http://toddheymandirector.com/index_mobile88.html 我哪里错了?

你用的jQuery.toggle错了,

.toggle( [duration ] [, complete ] )

Description: Display or hide the matched elements.

参见:jQuery.toggle

toggle 用于 show/hide 匹配的元素,而不是在您尝试使用它时在两个函数之间切换。


据我了解,您想使元素 "wobble" 向上和向下?

这应该有效:

$(".menu2").animate({top: '-=1512px'}, 500).animate({top: '+=1512px'}, 500)