In the following code, how can I make it so clicking the checkbox or input field doesn't toggle the row selection? I tried using the not() selector as in:
$('#example tbody').on('click', 'tr:not(input)', function () ...
In the following code, how can I make it so clicking the checkbox or input field doesn't toggle the row selection? I tried using the not() selector as in:
$('#example tbody').on('click', 'tr:not(input)', function () ...
This is called Event Bubbling.
jQuery stopPropagation bubble down
Use:
$('input').on('click', function (e) {
e.stopPropagation();
})
use e.stopPropagation()
on inputs:
$('#example tbody').on('click', ':input', function(e){
e.stopPropagation(); // stops the event to bubble up to the dom tree
}).on('click', 'tr', function () ...
:input
in jQuery selects all the form elements including checkboxes, radios, textareas, selects etc.