开发者

jquery livequery event triggered on EVERYTHING, not just selected element

开发者 https://www.devze.com 2022-12-24 22:56 出处:网络
I am attempting to use li开发者_如何学Pythonvequery.I unfortunately am stuck using jquery 1.2.6.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号