javascript - Fire ul tag click event not li with jquery -
how can impact click event ul tag not li jquery?
<!-- html --> <ul class="wrap"> <li>test1</li> <li>test2</li> <li>test3</li> </ul>
i tried jquery this.but doesnt work.
//javascript jquery("ul.wrap").not(jquery("ul > li")).click(function(){ //fire ul });
how can this?
events 'bubble' dom parent elements. need attach event ul
, , event on kid li
elements uses stoppropagation()
:
jquery("ul.wrap") .on('click', function(){ // something... }) .on('click', 'li', function(e) { e.stoppropagation(); });
javascript jquery html
No comments:
Post a Comment