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
Post a Comment