TheLion TheLion - 10 months ago 45
jQuery Question

Add css to specific cell in jquery datatables

I am using jquery and datatables in my project.

What I want now is to add CSS to cell on click of button i.e changing cell color.I only want to change single specific cell value not the entire row

I tried below method and it did not work

<table id="food">

<button id='button1'>Click me</button>

Here is the jquery


//Here I want to change row 1,col 3 to red color

var cell = table.row(1).column(3).node();



Answer Source

You can do something like this to get cell at column 3 and and row 2 (zero indexed)

var nodes = myTable.column(2).nodes();

Here is a demo