zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    学习方法与经验总结
    工具综合症?资料收集狂?
    SpringMVC 过滤器Filter使用解析
    Spring 管理Filter和Servlet
    pom.xml配置详解
    开发Java web应用程序的介绍
    java web构建学习(概念基础)
    题目1474:矩阵幂
    题目1473:二进制数
    Python strip()方法
  • 原文地址:https://www.cnblogs.com/chrisghb8812/p/5623755.html
Copyright © 2011-2022 走看看