阻断HTML冒泡(67)

发布时间 2023-10-16 16:08:07作者: 涂磊
<!DOCTYPE html">
<head>
<title>无标题文档</title>
<body>
</head>

<div style="background:#FC0; padding:30px 100px"  id = 'outer' onclick="alert('外')" "> 
          <div style="color:#FFF; background:#09F; padding:5px 20px" id = 'core' ></div>
 </div> 
 </body>
<script type = 'text/javascript'>
var core = document.getElementById('core');
core.addEventListener("click",  function(e) {
                                    alert('');
                                     e.stopPropagation();  },
                     false);
                     
</script>
<html>