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开发者_Python百科 > ul[id=color] > li ").live("click", function() {
alert($(this).html());
});
is not working. Please tell what can be the possible reason?.. Thanks
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"
精彩评论