How to access the checkbox inside a cell via row selection

How to access the checkbox inside a cell via row selection

zackelberryzackelberry Posts: 7Questions: 2Answers: 0

Hi I am new to DataTable and I have an issue, this maybe common but I'm stuck with it for days.
I have place a checkbox inside a cell of my DataTable
{"data": null,
render: function (data) {
return "<input type='checkbox' class='chkClass' />";
},}
and I want it to be checked/unchecked everytime the row is selected, I have tried what I saw online but to no avail here are my codes

$('#myTable tbody').on('click', 'tr', function () {
$(this).toggleClass('selected');
if ($(this).hasClass("selected")) {
$(this).closest("input[type='checkbox'].chkClass").eq(0).prop('checked', true);
} else {
$(this).closest("input[type='checkbox']").eq(0).prop('checked', false);
}
});

hoping for your kind support, TIA.

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.