jQuery - Different actions for when clicking on TR and TR > span -
i have put data html table. when clicking on tr, adds 'checked' attribute checkbox particular row.
however, have several rows containing same parent id inside span - when click parent id, should add 'checked' attribute rows id. approach have 2 different actions - 1 when click table row
$('tr').on('click', function() { ... stuff ... }); and action when click tr inside span
$('tr > span').on('click', function() { ... else }); problem is, when click on span runs first event aswell. tried playing around :not selector , .not() function, couldn't seem work.
here's code (only took relevant parts):
$('tr').on('click', function() { // checkbox action here }); $('tr > span').on('click', function() { // multiple checkbox actions here });
use .stoppropagation() stop bubbling :
$('tr > span').on('click', function(e) { e.stoppropagation(); // multiple checkbox actions here });
Comments
Post a Comment