bind,unbing,on,live,delegate绑定和解绑事件
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Web Project</title>
<style type="text/css">
.myred{
border:4px solid red;
}
</style>
<script src="js/jQuery1.11.1.js"></script>
<script src="js/jquery-migrate-1.2.0.js"></script>
<script type="text/javascript">
$(function() {
/* $("input").focus(function() {
$(this).css("background","pink");
}).blur(function() {
$(this).css("background", "");
});*/
/* $("input").bind('focus', function () {
$(this).css("background", "pink");
}).bind('blur', function () {
$(this).css("background", "");
});*/
//5分钟,用一个bind,绑定个事件
/* $("input").bind('focus', function () {
$(this).css("background", "pink");
}).bind('blur', function () {
$(this).css("background", "");
});*/
/*$("input").bind(
{
focus: function () {
$(this).css("background", "pink");
},
blur: function () {
$(this).css("background", "");
}
});*/
$("input").on(
{
focus: function () {
$(this).css("background", "pink");
},
blur: function () {
$(this).css("background", "");
}
});
//卸载所有事件,但是不能用()
// $("input").unbind("focus blur");
$("input").off("focus blur");
//live
$("ul").delegate("li",{
mouseover: function() {
$(this).css("background","pink");
},
mouseout: function () {
$(this).css("background", "");
}
});
$("#btnAdd").live('click',function() {
//深圳
var $obj = $("<li>深圳</li>");
$("ul").append($obj);
}
);
});
</script>
</head>
<body>
用户名:<input type="text"/>
密码:<input type="password"/>
<ul>
<li>北京</li>
<li>上海</li>
<li>广州</li>
</ul>
<input id="btnAdd" value="添加节点" type="button"/>
</body>
</html>
//JQuery的1.9版本以后不再支持 on , live 的函数事件 , 得 引进相应的 jquery-migrate-1.2.0.js插件包才行。
最新文章
- Android 中onSaveInstanceState和onRestoreInstanceState学习
- css定位position认识
- Box2D自定义重力
- 点击事件touches与ios的手势UIGestureRecognizer
- iTOP-4412 平台基础软件的安装和学习
- [Ogre][地形][原创]基于OgreTerrain的地形实现
- android APP是否需要缓存?+简单架构
- Scrum10-22
- bootstrap.css.map这个文件有何用处?该怎能使用它?
- C#中HashTable和快速排序的用法
- Cython入门Demo(Linux)
- Linux之Samba部署
- (转) Ensemble Methods for Deep Learning Neural Networks to Reduce Variance and Improve Performance
- Linux内核分析 期末总结
- 比酒量|2012年蓝桥杯B组题解析第三题-fishers
- js飘窗
- selenium+python定位元素的方法及使用
- hdu 5920(模拟)
- arguments对象与Rest参数
- OpenERP7.0中非admin帐号新增其它用户问题
热门文章
- LTE Module User Documentation(翻译5)——Mobility Model with Buildings
- iOS - UIKit
- [转载] linux 程序运行过程中替换文件
- DOS中文乱码解决
- 简单RTOS学习(一) uc/os-II 工程模板建立
- linux GO语言配置安装
- nexus 2.6需要jdk7才能跑起来
- java中的堆内存和栈内存
- 转! java 中“==” 与“ .equals ”比较
- 20160808_安装JDK7u79