Skip to content Skip to sidebar Skip to footer

Set Click Event On Leaf Node

i have this type of html :-
  • Activities
    • Physical1
      • Cricket
        • One Day<

Solution 1:

Sounds like you need to modify the HTML, Anyways try this:

Working Demo

$('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"