jQuery的on()是否支持这种livequery功能? [英] Does jQuery's on() support this kind of livequery feature?

查看:70
本文介绍了jQuery的on()是否支持这种livequery功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用livequery,我可以执行以下操作:

With livequery I can do the following:

$(".focusable").livequery(function() {
   $(this).focus();
});

我知道jQuery支持代表等的自定义函数,但是我没有看到任何让我认为jQuery可以完成本示例中livequery所做的事情.

I know that jQuery supports custom functions for delegates and the like but I'm not seeing anything that makes me think that jQuery can do what livequery is doing in this example.

$("body").on("???", ".focusable", function() {
   $(this).focus();
});

我希望这是有道理的.

推荐答案

您可以使用DOMNodeInserted事件:

$("body").on("DOMNodeInserted", ".focusable", function() {
   $(this).focus();
});

IE8及更高版本不支持此功能: https://developer.mozilla.org/en /DOM/DOM_event_reference

This is not supported by IE8 and older: https://developer.mozilla.org/en/DOM/DOM_event_reference

这篇关于jQuery的on()是否支持这种livequery功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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