• jquery 事件冒泡


    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
        <meta charset="utf-8" />
        <script src="jquery-3.3.1.js"></script>
        <script>
            $(function () {
                //事件冒泡
                $('div').click(function () {
                    alert($(this).attr('id'));
                });
                $('p').click(function () {
                    alert($(this).attr('id'));
                });
                $('strong').click(function () {
                    alert($(this).attr('id'));
                    return false; //停止冒泡
                });

            })
        </script>
    </head>
    <body>
        <div id="dv" style="300px;height:200px;background-color:yellow">
            <p id="p1" style="100px;height:100px;background-color:blue">
                <strong id="st">加粗</strong>
            </p>
        </div>
    </body>
    </html>

  • 相关阅读:
    LeetCode数据库178
    LeetCode数据库181
    LeetCode数据库177
    LeetCode数据库176
    HNOI2003 消防局的设立
    HNOI2001 产品加工
    Luogu P1020 关路灯
    NOIP2004 虫食算
    SP2713 GSS4-Can you answer these queries IV
    APIO2008 免费道路
  • 原文地址:https://www.cnblogs.com/dxmfans/p/9434789.html
Copyright © 2020-2023  润新知