<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试</title>
</head>
<body>
<input type="button" id="btn1" value="点击">
<div id="div1" style=" 200px; height: 200px; display: none;"></div>
<script>
window.onload=function(){
var oBtn=document.getElementById('btn1');
var oDiv=document.getElementById('div1');
oBtn.onclick=function(eve){
var oEvent=eve||event; //处理ie和火狐的兼容性问题
oDiv.style.display='block';
alert('按钮点击了');
oEvent.cancelBubble=true; //阻止冒泡
}
document.onclick=function(){
alert('冒泡');
}
}
</script>
</body>
</html>