Reputation: 2893
Sorry this may be a duplicated question, but couldn't able to find the solution any where in the web as well as in StackOverflow
Problem
I need to get the selected row id from jquery data table
My code what I have tried
$.each($("#myDataTable").dataTable().fnGetNodes(), function (i, row) {
var id = $(this).attr("id");
console.log(id)
});
The selected TR has the class row_selected selected
class="even row_selected selected"
So I need to get the id of the selected row based on this selected class, please help in solving this issue
Upvotes: 1
Views: 1889
Reputation: 58870
Use $()
API method to perform a jQuery selector action on the table's TR
elements.
For example:
$("#myDataTable").dataTable().$("tr.selected").each(function(){
var id = $(this).attr("id");
console.log(id);
});
Upvotes: 1