I am attempting to use li开发者_如何学Pythonvequery. I unfortunately am stuck using jquery 1.2.6.
This is my code:
$(document).ready(function() {
$('a.sort').livequery('click', function(event) {
alert('hello');
});
});
If I click ANYWHERE in the document, I get the alert 'hello'.
What exactly is wrong there? Is it some bug with jQ1.2.6 and livequery 1.1.1?
This same question was asked here but the question wasn't clear, and the answer didn't help.
Shucks...
livequery 1.1.1 is NOT compatible with jQuery 1.2.6. It only works with jQuery 1.3+
If you need to use a version < 1.3, then livequery 1.0.3 is the latest one that can be used.
Use the rel attribute:
$('a[rel*=sort]')
.livequery('click', function(event) {
alert('test');
});
Get rid of this: $(document).ready(function() { It is triggered for whole document, rather than requested element.
精彩评论