jquery click事件重复累加绑定
<div id="moveTree" onclick="treeLeft()">左移</div>
jquery click事件会重复累加绑定
??? function treeLeft(){
??? ??? alert("one");
?????? if($("#moveTree").attr("onClick")!=undefined)
??? ??? $("#moveTree").attr("onclick",'');
??? ??? $("#moveTree").click(function(){
??? ??? ??? treeRight();
??? ??? });
??? }
??? //目录居右
??? function treeRight(){
??? ??? alert("two");
??? ??? $("#moveTree").click(function(){
??? ??? ??? treeLeft();
??? ??? });
???
??? }
//连续单击“左移”,每次弹出了one、two会越来越多
应该在绑定新事件前,解除已有绑定
$("#moveTree").unbind("click");