jQuery中的bind和live方法有什么区别? [英] What is the difference between the bind and live methods in jQuery?

查看:66
本文介绍了jQuery中的bind和live方法有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇知道bind和live函数之间的区别.

I'm curious to know the differences between the bind and live functions.

在我看来,它们几乎是相同的.

To me they seem to be almost identical.

我阅读了实时/绑定方法的优点,但它没有不要告诉我区别...

I read the benefits of live/bind methods, but it didn't tell me about the differences...

谢谢!

推荐答案

.bind()将事件附加到在调用时已存在或与选择器匹配的元素.此后创建的任何元素或由于更改了类而匹配的元素都不会触发绑定事件.

.bind() attacheds events to elements that exist or match the selector at the time the call is made. Any elements created afterwards or that match going forward because the class was changed, will not fire the bound event.

.live()适用于现有和将来的匹配元素.在jQuery 1.4之前,此事件仅限于以下事件:click,dblclick mousedown,mouseup,mousemove,mouseover,mouseout,keydown,keypress,keyup

.live() works for existing and future matching elements. Before jQuery 1.4 this was limited to the following events: click, dblclick mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, keyup

这篇关于jQuery中的bind和live方法有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆