zoukankan      html  css  js  c++  java
  • jQuery事件和JSON点语法

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>

    <script src="jquery-1.11.2.min.js"></script>
    </head>

    <body>

    <div id="aa" style="100px; height:100px; background-color:#F93">hello</div>

    <input type="text" id="bd" />

    <input type="button" id="btn1" value="挂事件" />

    <input type="button" id="btn2" value="移除事件" />

    </body>

    <script type="text/javascript">

    //静态的加事件
    /*$("#aa").click(function(){

    })*/

    //挂事件(动态绑定事件)
    $("#btn1").click(function(){
    //给DIV绑定事件
    $("#aa").bind("click",function(){
    alert("div点击了");
    });
    })

    //移除事件
    $("#btn2").click(function(){
    //把DIV里面的事件移除掉
    $("#aa").unbind("click");
    })

    //事件数据
    //事件源
    $("#aa").keydown(function(e){
    alert(e.keyCode);
    })

    //JSON
    //$arr = array("one"=>"111")
    var j = {
    "one":"11111",
    "two":"22222",
    "three":"333333",
    "four":{"aa":"44411"}
    };

    //alert(j["two"]); //数组的取值方式
    //alert(j.two); //点语法
    //alert(j.four.aa);

    //遍历
    for(var k in j)
    {
    alert(j[k]);
    }


    </script>

  • 相关阅读:
    关于XML文档
    Why sql is called structured query language?1
    UML学习---交互
    C#为什么不采用多继承:
    url中
    array
    hard
    构造函数返回值
    布局容器layout Container
    k8s的概念
  • 原文地址:https://www.cnblogs.com/jc535201285/p/6524795.html
Copyright © 2011-2022 走看看