Reputation: 4550
Please help to determine the element.
Please check my example http://jsfiddle.net/fantill/DFd7e/
I want to get return from all li
after 2nd level but only selected one.
in css it should be ul ul li
.
My problem is if I write above way, jquery will return all matched element not only the one I chooses.
Either $('#A').find('ul ul li')
or $('#A ul ul li')
are the same result.
Usually $(this)
will be the chosen element, but I dont know why it doesnt work in this case.
Thank you very much for your advice and help.
Upvotes: 1
Views: 92
Reputation: 136094
I think what you're looking for is to stop propagation of the event up to its ancestors.
$('#A').find('ul ul li').click(function(e){
alert($(this).html());
e.stopPropagation();
});
Live example: http://jsfiddle.net/DFd7e/3/
Upvotes: 3