Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用datatable jquery插件的网格_Jquery_Jquery Ui_Datatables - Fatal编程技术网

使用datatable jquery插件的网格

使用datatable jquery插件的网格,jquery,jquery-ui,datatables,Jquery,Jquery Ui,Datatables,我正在使用数据表插件创建一个网格 我不能做的是,当数据表访问数据的数组中存在负值时,该值应显示为红色。只有该值的颜色应为红色,而不是整个单元格。有人能告诉我怎么做吗 小提琴是 如本例中所示,仅显示负值。我希望负值应该用红色表示。只有值应以红色显示,而不是整个单元格 代码是 $(document).ready(function() { $('#example').dataTable({"sPaginationType": "full_numbers"}); }); 是否仅在“版本”列中使

我正在使用数据表插件创建一个网格

我不能做的是,当数据表访问数据的数组中存在负值时,该值应显示为红色。只有该值的颜色应为红色,而不是整个单元格。有人能告诉我怎么做吗

小提琴是

如本例中所示,仅显示负值。我希望负值应该用红色表示。只有值应以红色显示,而不是整个单元格

代码是

$(document).ready(function() {
    $('#example').dataTable({"sPaginationType": "full_numbers"});
});

是否仅在“版本”列中使用该功能?不知道我是否真的得到了你想要的,但这里输入的代码应该适合你:

$(document).ready(function() {
  $('td:nth-child(4)').toArray().forEach( function (el) {
    $el = $(el);
    if ($el.html().length > 1 && $el.html()[0] === "-") {
      $el.css('color', 'red');
    }
  });
  $('#example').dataTable({"sPaginationType": "full_numbers"});
});​