damoblog
<html>
<head>
<script type="text/javascript">
function fnclick1(){
    alert("父元素弹窗")
}
function fnclick2(e){
    //阻止跳转到其它页面(如提交表单跳转等)
    //e.preventDefault();
    //阻止点击事件向上冒泡
    e.stopPropagation();
    alert("子元素弹窗");
}
</script>
</head>
<body>
<div onclick="fnclick1()">
    父点击事件
    <div onclick="fnclick2(event)">
       子点击事件
    </div>
</div>
</body>
</html>

 

分类:

技术点:

相关文章:

  • 2021-12-17
  • 2021-12-17
  • 2021-12-17
  • 2021-12-17
  • 2021-12-17
  • 2021-12-05
  • 2021-12-17
  • 2021-12-17
猜你喜欢
  • 2021-11-03
  • 2021-11-03
  • 2021-12-17
  • 2021-12-17
  • 2019-01-11
  • 2021-12-17
  • 2021-12-17
相关资源
相似解决方案