jquery/livequery not working in this particular case

好久不见. 提交于 2020-02-05 04:32:09

问题


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.......

The error is:

Uncaught TypeError: Object #<Object> has no method 'livequery' 

is it because of the wildcard? or a general jquery error?

Thank you


回答1:


If what you want to do is

Attach an event handler for all elements which match the current selector, now and in the future

Then this is the appropriate syntax:

$(document).on("click", "[class*='welcome']", function() {
    // do stuff
});

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.

Demo here: http://jsfiddle.net/zNXXk/



来源:https://stackoverflow.com/questions/11701340/jquery-livequery-not-working-in-this-particular-case

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!