我在我的项目中使用jQuery和数据表。添加CSS到jQuery数据表中的特定单元格
我现在想要的是CSS添加到细胞上的按钮,点击即改变细胞color.I只想改变单一的特定单元格的值不是整行
我尝试以下方法,它没有工作
<table id="food">
<thead>
<tr>
<th>Number</th>
<th>Name</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Apple</td>
<td>Fruit</td>
</tr>
<tr>
<td>2</td>
<td>Mango</td>
<td>Fruit</td>
</tr>
<tr>
<td>3</td>
<td>Grape</td>
<td>Fruit</td>
</tr>
</tbody>
</table>
<button id='button1'>Click me</button>
这里是jQuery的
$('#button1').click(function(){
//Here I want to change row 1,col 3 to red color
var cell = table.row(1).column(3).node();
$(cell).addClass('change-color');
});
感谢
你想更改CSS整个排?这个复选框在哪里?每行的第一列?请在问题 – Dhiraj
中更多描述你的情况嗨dhiraj, 删除所有不必要的东西..现在问题看起来简单明了.. – TheLion
你可以请提供表格的HTML吗? – Wazaaaap