How to get class from jquery datatable string object?

I have a jquery datatable line:

table = $('#reports').DataTable() row = table.row(rowIndex) 

How do I get the html class? (it is striped, and I want to find out if it’s not strange or even.

I tried:

 row.hasClass('odd') row.className row.attr('class') 

any ideas?

+6
source share
3 answers

Use node with className :

 row.node().className; 
+4
source

Really good question. The usual jQuery way using row.index() :

 var rowClass = $("#example tbody tr:eq("+row.index()+")").attr('class'); 

proof of concept β†’ http://jsfiddle.net/7jy46wz4/

+2
source

Taking what @ rick-hitchcock said, another approach is to use the following code in validation:

 var hasOddClass = $(row.node).hasClass("odd"); 

which, according to the examples you have given, should be closer to what you want.

0
source

Source: https://habr.com/ru/post/983446/


All Articles