
我想点右边图标然后取消下面红框点的点击事件
然后再点空白处就还原红框里的点击事件,为什么
会没有反应,重绑不了了
/*******js*******/
//红框的绑定事件
$(".accessPage section>dl>dd li:nth-of-type(1)").bind("click",function(){
location.href="access_2.html";
});
$(".accessPage section>dl>dd li:nth-of-type(2)").bind("click",function(){
location.href="#";
});
//委托到document身上
$(document).delegate("span[class=tabsel]", "click", function(event) {
event.stopPropagation();
//点击取消事件绑定
$(".tabsel").each(function() {
$(".accessPage section>dl>dd li:nth-of-type(1)").unbind("click");
$(".accessPage section>dl>dd li:nth-of-type(2)").unbind("click");
});
//点击空白处重新绑定
$(document).click(function() {
$(".accessPage section>dl>dd li:nth-of-type(1)").bind("click");
$(".accessPage section>dl>dd li:nth-of-type(2)").bind("click");
});
});
/*******html*******/
-
- DGD0000000001
- 大股东00012
-
- 代理2
- 客户
- 10
-
- DGD0000000001
- 大股东00012
-
- 代理2
- 客户
- 10
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
bind函数是需要两个参数的,你的重新绑定的代码这样
.bind("click");只有一个参数,肯定不行的。建议两种修改方案:
1. 加个标志位就搞定了,不需要什么解绑定、重新绑定:
http://codepen.io/lishengzxc/pen/jPLdPm