jQuery/LiveQuery在这种特定情况下不起作用 [英] jquery/livequery not working in this particular case
本文介绍了jQuery/LiveQuery在这种特定情况下不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用jquery时,我所有的其他livequery函数都可以正常工作,对于这个特定的函数我遇到了错误...
Using jquery, all of my other livequery functions work fine, i am getting an error for this particular one...
$("[class*='welcome']").livequery("click", function(e){ etc.......
错误是:
Uncaught TypeError: Object #<Object> has no method 'livequery'
是因为通配符吗?还是一般的jQuery错误?
is it because of the wildcard? or a general jquery error?
谢谢
推荐答案
如果您想做的事
为现在和将来与当前选择器匹配的所有元素附加事件处理程序
Attach an event handler for all elements which match the current selector, now and in the future
然后这是适当的语法:
$(document).on("click", "[class*='welcome']", function() {
// do stuff
});
jQuery的 live()
函数曾经是首选,但已弃用从jQuery 1.7开始支持 on()
.
jQuery's live()
function used to be the way to go, but it has been deprecated in favor of on()
as of jQuery 1.7.
此处演示: http://jsfiddle.net/zNXXk/
这篇关于jQuery/LiveQuery在这种特定情况下不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文