• Bind()事件


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
    </head>
    <body>
        <div id="content">
            外层div元素<br />
            <span>内层span元素</span><br />
            外层div元素
        </div>
        <div id="msg"></div>
        <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {
                $("span").bind("click", mySpan = function (event, a, b) {
                    var txt = $("#msg").html() + "<p>内层span元素被单击<p/>";
                    $("#msg").html(txt);
                    //alert($(event.target));
                    event.stopPropagation();
                    start(event, a, b);
                    //return false;
                })
                $("span").trigger("click", ["5", "6"]);
                function start(event, a, b) {
                    alert(a);
                    alert(b);
                }
                $("#content").bind("click", { foo: "bar" }, myFun2 = function (event) {
                    var txt = $("#msg").html() + "<p>外层div元素被单击<p/>";
                    $("#msg").html(txt);
                    alert(event.data.foo);
                    event.stopPropagation();
                });
                $("body").trigger("clcik");
                $("body").bind("click", function () {
                    var txt = $("#msg").html() + "<p>body元素被单击<p/>";
                    $("#msg").html(txt);
                    event.stopPropagation();
                });
    
    
                $("#btn").click(function () {
                    $("#btn").unbind("click", myFun2);
                    alert("aaa");
                })
            })
        </script>
        <button id="btn">删除第二个</button>
        <div id="test"></div>
    </body>
    </html>

  • 相关阅读:
    搜索框
    鼠标hover时改变图片透明度和颜色(方法二)
    让背景带上颜色
    右侧固定导航栏
    react native环境配置
    左侧固定导航栏
    鼠标hover时改变图片透明度和颜色
    androidSDK配置环境变量
    cordova插件开发
    Python电子书分享
  • 原文地址:https://www.cnblogs.com/chrisghb8812/p/5623755.html
Copyright © 2020-2023  润新知