jquery - How to differentiate event handler for handling checkbox change event -


i have got 2 parts of html page .

one search , table

inside table ids checkboxes generated dynamically such 124 , 125 --- , check box under search section of id searchcheckboxid

is possible distinguish event handler when checkbook checked or unchecked both sections ??

means if checkbox clicked inside table

i want call event handler

$(document).on('change','input[type="checkbox"]' ,function(){  alert('clicked on table checkbox');      }); 

and if clicked searchcheckboxid under search section , want call different handler .

please let me know how ??

http://jsfiddle.net/vxe2d2hh/26/

change selector target checkboxes descendants of table

$(document).on('change','table input[type="checkbox"]' ,function(){      alert('clicked on table checkbox');             }); 

demo: fiddle


if table static , rows added dynamically bind delegated handler table instead of document object. improve performance since change events outside of table ignored handler

$('table').on('change', 'input[type="checkbox"]', function () {     alert('clicked on table checkbox'); }); 

demo: fiddle


Comments