地狱的镰刀

bind(type,[data],fn) 为每个匹配元素的特定事件绑定事件处理函数。

$("a").bind("click",function(){alert("ok");});

live(type,[data],fn) 给所有匹配的元素附加一个事件处理函数,即使这个元素是以后再添加进来的

$("a").live("click",function(){alert("ok");});

delegate(selector,[type],[data],fn) 指定的元素(属于被选元素的子元素)添加一个或多个事件处理程序,并规定当这些事件发生时运行的函数

$("#container").delegate("a","click",function(){alert("ok");})

on(events,[selector],[data],fn) 在选择元素上绑定一个或多个事件的事件处理函数

差别:

.bind()是直接绑定在元素上

.live()则是通过冒泡的方式来绑定到元素上的。更适合列表类型的,绑定到document DOM节点上。和.bind()的优势是支持动态数据。

.delegate()则是更精确的小范围使用事件代理,性能优于.live()

.on()则是最新的1.9版本整合了之前的三种方式的新事件绑定机制

用三种方式写光棒效果

一:js批量注册this的说法

当通过循环的方式注册事件的时候,在匿名函数的方法体中,必须使用this代表当前对象,不能使用数组名[i](对象名)。

js设置样式的两种方案:

1.this.style.属性名=“属性值”;

如果属性名:

background-color--------->backgroundColor

font-size---------->fontSize

2.this.style.cssText="属性名:属性值;font-size:50px"

eg:

<script type="text/javascript" src="jq/jQuery1.11.1.js"></script>
<script type="text/javascript">
//用js的光棒效果
/* $(function(){
var hu=document.getElementsByTagName("li");
for(var i=0;i<hu.length;i++){
hu[i].onmouseover=function(){
//js方式设计样式 方式一 this.style.属性名=属性值。
//this.style.background="red";
// this.style.fontSize="40px";
//方式二:this.style.cssText="属性名:属性值"
this.style.cssText="background:pink;font-size:50px;";
}; hu[i].onmouseout=function(){
//方式一:
this.style.background="";
this.style.fontSize="20px";
//方式二:
// this.style.cssText="background:;font-size:20px;";
};
}

用jq的两种方法:

//用jq的光棒效果  1.锁定li元素
$(function(){
var hu=$("li");
hu.mouseover(function(){
$(this).css({"background":"pink","font-size":"50px"});
}).mouseout(function(){
this.style.background="";
this.style.fontSize="20px";
});
});
//hover的光棒效果
ji.hover(
function(){
$(this).css({"background":"pink","font-size":"50px"});
},function(){
this.style.background="";
this.style.fontSize="20px";
});

复杂动画:

//复杂动画
$(function(){
$("img").animate({width:"90%"},5000)
.animate({height:"90%"},{queue:false,duration:5000})
.animate({borderWidth:5},{queue:false,duration:5000});
}); </script>
</head> <body>
<img src="img/1.jpg" style="width:100px; height:100px;display:none;"></img>
</body>

简单动画:

<script type="text/javascript" src="jq/jQuery1.11.1.js"></script>
<script type="text/javascript">
//简单动画
$(function(){
//$("img").show(5000,playDog);
//$("img").fadeIn(5000,playDog);
$("img").slideDown(5000,playDog);
});
function playDog(){
alert("will is power");
}
</script>
</head> <body>
<img src="img/1.jpg" style="width:100px; height:100px;display:none;"></img>
</body>

jQuery中.bind() .live() .delegate() .on()的区别 和 三种方式写光棒事件 动画的更多相关文章

  1. JavaScript--------------------jQuery中.bind() .live() .delegate() .on()的区别 和 三种方式写光棒事件 动画

    bind(type,[data],fn) 为每个匹配元素的特定事件绑定事件处理函数. $("a").bind("click",function(){alert( ...

  2. jquery中bind,live,delegate,on的区别

    这几种方法都是绑定事件用到的,但是他们之间有些差别 bind(type,[data],fn) 为每个匹配元素的特定事件绑定事件处理函数 例如: <ul> <a href=" ...

  3. 【转】jQuery中.bind() .live() .delegate() .on()的区别

    bind(type,[data],fn) 为每个匹配元素的特定事件绑定事件处理函数 $("a").bind("click",function(){alert(& ...

  4. jQuery中.bind() .live() .delegate() .on()的区别

    bind(type,[data],fn) 为每个匹配元素的特定事件绑定事件处理函数 $("a").bind("click",function(){alert(& ...

  5. jQuery中bind() live() delegate() on() 的区别

    实例 bind(type,[data],fn) 为每个匹配元素的特定事件绑定事件处理函数 $("a").bind("click",function(){aler ...

  6. jQuery中.bind() .live() .delegate() .on()区别

    $(selector).bind(event,data,function) $(selector).live(event,data,function)//jquery1.9版本以下支持,jquery1 ...

  7. jQuery中bind方法和live方法区别解析

    Javascript中的事件有它的独特性,有默认的执行事件,例如冒泡就是其中的一个.在很多比较复杂的应用程序中,停止事件的冒泡或捕获在程序开发当中是十分有用的,而在IE中有它的独特方式来阻止事件的冒泡 ...

  8. 谈 jquery中.band() .live() .delegate() .on()的区别

    bind(type,[data],fn) 为每个匹配元素的特定事件绑定事件处理函数 $("a").bind("click",function(){alert(& ...

  9. 监视EntityFramework中的sql流转你需要知道的三种方式Log,SqlServerProfile, EFProfile

    大家在学习entityframework的时候,都知道那linq写的叫一个爽,再也不用区分不同RDMS的sql版本差异了,但是呢,高效率带来了差灵活性,我们 无法控制sql的生成策略,所以必须不要让自 ...

随机推荐

  1. leetcode day5

    [242]Valid Anagram: Given two strings s and t, write a function to determine if t is an anagram of s ...

  2. onethink微博插件雏形记

    2014年7月30日 17:08:44 后台微博插件: 一.功能: 1.绑定微博 2.发布的文章自动发布到新浪微博 3.插件独立性强,修改地方少 二.效果: 插件目录 工程地址:http://down ...

  3. UVa 10346 - Peter's Smokes

    题目大意:Peter有n支烟,每k个剩下的烟头可以卷成一支新烟,问Peter能吸多少跟烟? 简单数学题. #include <cstdio> int main() { #ifdef LOC ...

  4. 云脉推出表格识别API接口可以自助接入

    针对如今市场上对于海量票据信息的录入需求,近期厦门云脉技术有限公司推出票据识别相关的产品与服务,更是在云脉OCR SDK开发者平台上上线表格识别API接口,供广大开发者和集成商自助接入.为了降低财务系 ...

  5. php循环生成的表单如何获得其各项值案例

    思路:输入框和按钮是用for循环生成的,不但要获取输入框里的各项值,并且要获取点击按钮的值,要知道是那个按钮被点击了,这里以生成5个为例.如图: 这是提交页面,点击的是“小米”. 这是显示结果,测试显 ...

  6. 前端程序员应该知道的 15 个 jQuery 小技巧

    下面这些简单的小技巧能够帮助你玩转jQuery. 返回顶部按钮 预加载图像 检查图像是否加载 自动修复破坏的图像 悬停切换类 禁用输入字段 停止加载链接 切换淡入/幻灯片 简单的手风琴 让两个div高 ...

  7. --@angularJS--独立作用域scope绑定策略之&符策略

    1.index.html: <!DOCTYPE HTML><html ng-app="app"><head>    <title>s ...

  8. LINQ 的查询_联表、分组、排序

    1.查询 var v = from s in db.Set<ScoreInfo>().ToList()group s by s.subject into scoreselect new{  ...

  9. 在ASP.NET MVC中使用 Bootstrap table插件

    Bootstrap table: http://bootstrap-table.wenzhixin.net.cn/zh-cn/getting-started/ 1. 控制器代码: using Syst ...

  10. Word常用实用知识3

    纯手打,可能有错别字,使用的版本是office Word 2013 转载请注明出处 http://www.cnblogs.com/hnnydxgjj/p/6322813.html,谢谢. 分页符分页 ...