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>

原文地址:https://www.cnblogs.com/jc535201285/p/6524795.html