我给section里的标签都邦定了click事件,
我想点其中的input时取消其它标签的绑定事件,
再点击p点才重新恢复其它的事件绑定功能,
这个要怎么改,我下面不行,取消绑定事件就绑不回来了!!!
<style>
section{overflow:hidden;}
input,font,span{width:100px;height: 30px;display:block;background:red;margin:0 10px;float:left;text-align: center;line-height: 30px;font-weight:bold;}
p{width:360px;height:300px;background:#000;overflow:hidden;display: none;}
</style>
<section>
<input type="button" value="input"/>
<font>font</font>
<span>span</span>
</section>
<p>p</p>
<script>
$(function(){
$("input").bind("click",function(){
$("font").unbind("click");
$("span").unbind("click");
$("p").show(function(){
$(this).click(function(){
$("font").bind("click");
$("span").bind("click");
$(this).hide();
})
});
});
$("font").bind("click",function(){
alert("font");
});
$("span").bind("click",function(){
alert("span");
});
})
</script>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
<script> $(function(){ var flag; $("input").bind("click",function(){ flag=fasle; $("p").show(function(){ $(this).click(function(){ flag=true; $(this).hide(); }) }); }); $("font").bind("click",function(){ if(flag){ alert("font"); } }); $("span").bind("click",function(){ if(flag){ alert("font"); } }); }) </script>
你的绑定的事件处理函数独立为一个函数就OK啦~~~
point-event:none
把绑定的事件拿出来,写成一个函数