我有三个框,其中包含我想用我已经编码的特定动画打开的信息。我已经编写了所有内容,当单击一个时,其他的会关闭,但是我似乎无法弄清楚当您第二次单击名称时如何关闭该框,我不知道为什么,但是尝试时切换事件不起作用。知道我该怎么做吗?这是jquery代码:
$('.link').click(function(){
$('#box').animate({
marginLeft:"0px",
marginTop:"100px"
},500).addClass('navigation').animate({
width:"260px",
height:"80px"
},500);
$('#box2').animate({
marginLeft:"100px",
marginTop:"0px",
width:"60px",
height:"23px"
},500).removeClass('navigation');
$('#box3').animate({
marginLeft:"200px",
marginTop:"0px",
width:"60px",
height:"23px"
},500).removeClass('navigation')
});
$('.link2').click(function(){
$('#box2').animate({
marginLeft:"0px",
marginTop:"100px"
},500).addClass('navigation').animate({
width:"260px",
height:"80px"
},500);
$('#box').animate({
marginLeft:"0px",
marginTop:"0px",
width:"60px",
height:"23px"
},500).removeClass('navigation');
$('#box3').animate({
marginLeft:"200px",
marginTop:"0px",
width:"60px",
height:"23px"
},500).removeClass('navigation');
});
$('.link3').click(function(){
$('#box3').animate({
marginLeft:"0px",
marginTop:"100px"
},500).addClass('navigation').animate({
width:"260px",
height:"80px"
},500);
$('#box2').animate({
marginLeft:"100px",
marginTop:"0px",
width:"60px",
height:"23px"
},500).removeClass('navigation');
$('#box').animate({
marginLeft:"0px",
marginTop:"0px",
width:"60px",
height:"23px"
},500).removeClass('navigation');
});
这里有一个 jsfiddle 让它更清楚:http: //jsfiddle.net/Unphr/11/