是否不推荐使用jquery .bind()? [英] Is jquery .bind() deprecated?

查看:439
本文介绍了是否不推荐使用jquery .bind()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jquery bind()是否已弃用或可以安全使用?

Is jquery bind() deprecated or it can be used safely?

我看到很多关于bind()的评论都在SO的评论和答案中被弃用,例如:

I see a lot of comments about bind() being deprecated in comments and answers across SO like: Jquery Event : Detect changes to the html/text of a div

是否有JavaScript/jQuery DOM更改侦听器?

并且不知道使用它是否安全(不管它的好坏).

and don't know if it is safe to use it or not (regardless of it being better or worse).

这里不建议使用它: https://api.jquery.com/bind/

推荐答案

我不认为它已被弃用,但on是附加事件的首选方法.

I don't believe its deprecated but on is the preferred method of attaching events.

http://api.jquery.com/bind/

已弃用意味着他们将来会删除它,但是他们的文档似乎没有这么说.

Deprecated means they will be removing it in the future but their docs don't seem to say that.

自jQuery 3.0起,不推荐使用bind.上面的链接仍然有用,但是已经更新.从他们的文档中:

As of jQuery 3.0 bind IS deprecated. The above link is still relevant but has since been updated. From their docs:

自jQuery 3.0起,.bind()已被弃用.被它取代 .on()方法,用于将事件处理程序附加到文档,因为 jQuery 1.7,因此不鼓励使用它.

As of jQuery 3.0, .bind() has been deprecated. It was superseded by the .on() method for attaching event handlers to a document since jQuery 1.7, so its use was already discouraged.

这篇关于是否不推荐使用jquery .bind()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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