【发布时间】:2011-06-23 07:58:25
【问题描述】:
我目前有一个包含 3 个链接的菜单,它打开隐藏的 div 与自身相关的内容并使用此 jquery 代码(见下文),但希望如果一个 div 在打开第二个 div 时打开,它会关闭原始打开的 div ...
即如果“foobox”打开,然后用户点击“foo2”打开“foobox2”,“foobox”将关闭
$('#foo').toggle(function(){
$('#foobox').animate({marginLeft: '354'}, 1000);
},
function(){
$('#foobox').animate({marginLeft: '0'}, 1000);
});
$('#foo2').toggle(function(){
$('#foo2box').animate({marginLeft: '354'}, 1000);
},
function(){
$('#foobox3').animate({marginLeft: '0'}, 1000);
});
$('#foo3').toggle(function(){
$('#foobox3').animate({marginLeft: '354'}, 1000);
},
function(){
$('#foobox3').animate({marginLeft: '0'}, 1000);
});
像往常一样提前谢谢你。
【问题讨论】:
标签: jquery toggle jquery-animate