admin管理员组文章数量:1388134
I need to loop inside my Datatable, and I want to change background-color attribute only in some rows at specific index, so I need to have control over the index of the table.
My idea is to extract a single tr on a specific position, so I was trying to write this code, I don't have any error in console, I see it prints the correct number of index for each row, but nothing happen on the table, the css is not applied.
var myTable = $('#food').DataTable();
$('#button').on('click', function () {
$('#food > tbody > tr').each(function(index, tr) {
console.log(index);
$("#food tr:nth-child("+index+")").addClass('change-color');
});
});
.change-color{
background-color: #FFFFAC;
}
本文标签: javascriptLoop in Jquery DataTable and change css only in specific rowsStack Overflow
版权声明:本文标题:javascript - Loop in Jquery DataTable and change css only in specific rows - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744551141a2612190.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论