<input id='btn1' type='button' value='显示' />
<div id="div1"></div>
#div1 {
width: 100px;
height: 100px;
background: #ccc;
}
window.onload = function() {
var oBtn = document.getElementById('btn1');
var oDiv = document.getElementById('div1');
oBtn.onclick = function(ev) {
var oEvent = ev || event;
oDiv.style.display = 'block'
//阻止冒泡事件
oEvent.cancelBubble = true;
};
document.onclick = function() {
oDiv.style.display = 'none'
};
};