想禁止掉页面的其它click事件,用true||false就可以避免去取消事件的绑定
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<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;}
div{width:360px;height:300px;background:#000;overflow:hidden;display: none;}
</style>
</head>
<body>
<section>
<input type="button" value="input"/>
<font>font</font>
<span>span</span>
</section>
<div>div</div>
<script>
$(function() {
var flag=true;
$("input").bind("click", function() {
flag=false;
$("div").show(function() {
$(this).click(function() {
$(this).hide();
flag = true;
})
});
});
$("font").bind("click", function() {
if (flag) {
alert("font");
}
});
$("span").bind("click", function() {
if (flag) {
alert("span");
}
});
});
</script>
</body>
</html>