Accessing other cells in the same row on click td
Accessing other cells in the same row on click td
RolandH
Posts: 1Questions: 1Answers: 0
When clicking on a cell, I can get the value of the cell and change it. How do I change the value of the cell next to it?
$('#mytable tbody').on( 'click', 'td', function () {
var table = $('#mytable').DataTable();
var cell = table.cell( this );
var val = cell.data();
console.log(val); // current value
cell.data( 'new value' ).draw(); change the value of the clicked cell.
});
This discussion has been closed.
Answers
Hi RolandH,
The API method
.cell().index()
can tell you details about the cell you have, then you can tweak it to get the neighbouring cell, as in this example.Cheers,
Colin