开发者

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"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜