题解 | #阻止冒泡事件#
阻止冒泡事件
https://www.nowcoder.com/practice/1c12ccea98b049078d2cd3ef39269856
<html>
<head>
<meta charset=utf-8>
</head>
<body>
<ul>
<li>nowcoder</li>
</ul>
</body>
<script type="text/javascript">
// 补全代码
var liEl= document.getElementsByTagName('li')[0];
liEl.addEventListener("click",function(e){
e.stopPropagation();
})
</script>
</html>
<head>
<meta charset=utf-8>
</head>
<body>
<ul>
<li>nowcoder</li>
</ul>
</body>
<script type="text/javascript">
// 补全代码
var liEl= document.getElementsByTagName('li')[0];
liEl.addEventListener("click",function(e){
e.stopPropagation();
})
</script>
</html>