I can easily catch click event of a checkbox as shown below:
<input type="checkbox" id="checkbox1" />
$('#checkbox1').change(function () {
if (this.checked) {
//Do stuff
}
});
On the other hand, I create a checkbox on callback of AJAX (in jQuery DataTable) as HTML and click event of the same element cannot be catched:
//...
"ajaxSource": "/Student/GetStudents",
"fnServerData": function (sSource, aoData, fnCallback) {
aoData.push({ "name": "all", "value": all });
$.getJSON(sSource, aoData, function (json) {
fnCallback(json);
$("div.toolbar").html('<input type="checkbox" id="checkbox1" /> Get all records');
});
},
What is the most suitable method to get the checkbox value in the HTML string?