问题
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