<!doctype html>
<html>
<head>
<style>
.box{width:200px;height:200px;background-color:green;}
span{display:block;width:100px;height:30px;background-color:skyblue;}
</style>
<script src="jquery.js"></script>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<span>按我</span>
<div class="box">消失的盒子</div>
<script>
//点span显示盒子
$("span").click(
function(){
event.stopPropagation()//阻止事件冒泡
$(".box").show()
}
)
//点文档隐藏盒子
$(document).click(
function(){
$(".box").hide()
}
)
</script>
</body>
</html>