001priyank
001priyank

Reputation: 517

Jquery live click problem

I am using jquery 1.3.2 library. and (jquery 1.8.7 js and css)

Now,

$("div > ul[id=color] > li ").live("mouseover", function() {    
    alert($(this).html());
});

is working but,

$("div > ul[id=color] > li ").live("click", function() { 
    alert($(this).html());
});

is not working. Please tell what can be the possible reason?.. Thanks

Upvotes: 0

Views: 842

Answers (1)

David Tang
David Tang

Reputation: 93684

It is possible that a descendant or anscestor element has an onclick handler that returns false or calls event.stopPropagation(). Since .live() relies on the event travelling all the way up to the document level, if the event is blocked anywhere along the element tree then your handler won't be called.


Sidenote: IDs are unique, and jQuery has a shortcut for them, therefore your selector can be simplified to:

"#color > li"

Upvotes: 4

Related Questions