html - create a group of checkboxes with a click event associated Javascript -


i'm creating javascript function builds table checkboxes. want associate click event them. event must same all.

this part of code:

var = 0; (i = 0; < data.items.length; i++) {     var tr = $(document.createelement('tr'));     tr.addclass("mybookings_table_content");     $("#mybookings_table").append(tr);      //create checkbox element     var chkbox = document.createelement('input');     chkbox.type = "checkbox";     chkbox.id = "chk"+i.tostring();     chkbox.name = "chk" + i.tostring();     //event here } 

can me?

since using jquery, can add event listener :

$("#mybookings_table").on("click", "input[type=checkbox]", clickcb);  function clickcb() {     var $cbx = $(this);      // code on checkbox } 

this code appended after loop, see fiddle : http://jsfiddle.net/6f79pd5y/


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -