Set Click Event On Leaf Node
i have this type of html :-
- Activities
- Physical1
- Cricket
- One Day<
- Cricket
- Physical1
Solution 1:
Sounds like you need to modify the HTML, Anyways try this:
$('li:not(:has(*))').click(function(){
$('#result').text($(this).text());
});
<div id="result"></div>
Solution 2:
This will select all li with no children. Then just attach click event. (assuming valid HTML)
$('li:not(:has(*))').click(.....)
Post a Comment for "Set Click Event On Leaf Node"