This code of mine is NOT working. What is it that i am doing wrong?
$("#checkall").click(function () {
$("input", myTable.fnGetNodes()).each(function () {
$("input", myTable.fnGetNodes()).prop("checked", this.checked);
});
});
It seems the current value of this inside .each function cannot have the property checked. Where am i going wrong?
This is my markup
<table class="table display" id="userviewtable">
<thead>
<tr>
<th id="checkall"><input type="checkbox" /></th>
<th>User ID</th>
<th>User Name</th>
<th>Staff ID</th>
</tr>
</thead>
<tfoot>
<tr>
<th><input type="checkbox" /></th>
<th>User ID</th>
<th>User Name</th>
<th>Staff ID</th>
</tr>
</tfoot>
</table>
And on the script side i have the following:
var myTable=$("#userviewtable").dataTable(); //to initialize my table with data
$("#checkall").click(function () {
$("input", myTable.fnGetNodes()).each(function () {
$("input", myTable.fnGetNodes()).prop("checked", this.checked);
});
});
Thank you