zoukankan      html  css  js  c++  java
  • 阻止冒泡

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>阻止冒泡</title>
    </head>
    <body>
        <div class="box1">
            <div class="box2">
                <div class="box3">内容</div>
            </div>
        </div>
        
    </body>
    <script type="text/javascript" src="jquery-1.7.2.js"></script>
    <script type="text/javascript">
        $(function(){
            $('.box3').click(function(){
                alert('box33333')
                stopBubble();
            });
            $('.box2').click(function(){
                alert('box2222')
            });
            $('.box1').click(function(){
                alert('box1111')
            });
    
                function stopBubble(e)
            {
                if (e && e.stopPropagation)
                    e.stopPropagation()
                else
                    window.event.cancelBubble=true
            }
            return false
        })
    
    
    
    </script>
    </html>
  • 相关阅读:
    Fire
    Apple Tree
    访问艺术馆
    三角关系
    字母表
    折纸
    旅行
    单词分类

    圆桌游戏
  • 原文地址:https://www.cnblogs.com/jinsuo/p/7726281.html
Copyright © 2011-2022 走看看