Jquery checkbox checked after clicking one checkbox -
i have 1 table.inside table have 2 <td>
.first <td>
has 1 checkbox , second <td>
has sections contains checkboxes.onclick of checkbox of first <td>
,it should check checkboxes of other <td>
.this code using datatable.
for (var = 0; < tmpcolumns.length; i++) { var obj = new object(); var table = ""; obj.title = tmpcolumns[i].touppercase(); obj.data = tmpcolumns[i]; obj.defaultcontent = ""; columns.push(obj); if(type == "table" && == 0) { obj.render = function (data, type, row, meta) { table = row.name; select = '<section> <label class="checkbox" style="padding-left: 1em;"><input type="checkbox" id = "checkall" " data-table-name="' + table + '">' + table + ' <i></i></label></section>'; return select; } } if(type == "table" && == 1) { obj.render = function (data, type, row, meta) { table = row.name; (var j = 0; j < data.length; j++) { var column = table + "." + data[j]; ele = ele + '<section> <label class="checkbox" style="padding-left: 1em;"><input type="checkbox" class="addtoquery" data-col="' + column + '" data-table="' + table + '"><i></i>' + data[j] + '</label></section>'; } return ele; }; break; } }
this code checking checkbox after clicking first checkbox.
$("#tablelist").on("change",'input[data-table-name]', function () { var bool = $(this).prop('checked'); var tablename = $(this).attr("data-table-name"); $('input[data-table="' + tablename + '"]').prop("checked", bool); });
i want check particular checkbox in in same <tr>
.but checking <tr>
elements thanks.
$("#tablelist").on("change",'input[data-table-name]', function () { $(this).closest("tr").find('input[data-table="' + tablename + '"]').prop("checked", $(this).prop('checked')); });
Comments
Post a Comment