stop()

功能

防止传播和破坏传递事件的默认动作。与调用event.preventdefault()和event.stopPropagation()一样。

语法

eventer.stop(event)

参数

  • event
    要停止的事件对象

范例

Example: 点击button停止事件,或继续事件。

<!DOCTYPE html>
<html>

<head>
    <style>

    </style>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script>
    <script>
    require.config({
        baseUrl: "./",
        packages: [
            { name: "skylark", location: "../../../src/skylark" },
        ]
    });
    </script>
</head>

<body>
    <div>
        <button class="stop">stop click</button>
        <button class="not-stop">click</button>
    </div>
    <p></p>
    <script>
    require(["skylark/query", "skylark/eventer"], function($, eventer) {
        $("button.stop").click(function(e) {
            eventer.stop(e);
            $("p").html("trigger by stopped button! ");
        });

        $("button.not-stop").click(function(e) {
            $("p").html("trigger by not stopped button !");
        });

        $("div").click(function(e) {
            $("p").append(" so you can see div msg").style("color", "red");
        });
    });
    </script>
</body>

</html>