eclipsis eclipsis - 2 years ago 146
Javascript Question

DataTables: Add class to table cells, but not table headers?

I'm using the following code to initialize jQuery DataTables:

var oTable = $('#qpidvulh_to-do_list').dataTable( {
"columns": [
"data": "item",
"className": "editable"
} )

The issue with this code is that it adds the
class to the
of each column, even though I only want it added to the
of each column.

How can I get the code to only add the
class to the cells of each column and not their headers?

Answer Source

Thanks to mainguy and markpsmith for posting their answers. I'll throw my own solution into the mix, but I'd still like to see what everyone thinks the best performing solution would be:

$('#qpidvulh_to-do_list thead th').removeClass('editable');

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download