通过按第一个按钮,您将为第二个按钮设置动画margin-left
,通过按第二个按钮,您将单击事件与第一个按钮解除绑定,但我想说第三个按钮将单击事件绑定回第一个按钮。
当然寻找一个简单的解决方案!
这是代码的样子:
<div class="button"><a href="http://www.google.com">something</a></div>
<div class="button2"><a href="http://www.google.com">something2</a></div>
<div class="button3"><a href="http://www.google.com">something3</a></div>
(function(){
$('.button a').on('click', function(e){
e.preventDefault();
$('.button2').animate({'margin-left': '+=2'}, 100);
})
$('.button2').on('click', function(e){
e.preventDefault();
$('.button a').unbind('click');
})
$('.button3').on('click', function(e){
e.preventDefault();
$('.button a').bind('click');
})
})();
你可以在这里弄乱它