2017-08-15 46 views
0

当某个值出现错误时,我尝试突出显示某一行,而是突出显示mouseover上的每一行。Datatables - 突出显示mouseover上的行

我的错误在哪里?

https://jsfiddle.net/p0np06mx/

$('#table1').DataTable({ 
     "bFilter" : false, 
     "ordering": true, 
     columnDefs: [{ 
     orderable: false, 
     targets: "no-sort"}], 
     "paging": false, 
     drawCallback: function (settings) { 
     $('#table1 tr').each(function() { 
      var Cell = $(this).find('td:eq(3)'); 
      debugger; 
      if (Cell.text() !== 'error') { 

       $(this).find('button').hide(); 
       $(this).find('textarea').hide(); 

      }else{ 

       $(this).parent().on('mouseover', 'tr', function() { 
        $(this).css('background-color', '#ff6900'); 

        $(this).bind("mouseout", function(){ 
         $(this).css('background-color', ''); 
        }); 

       }); 
      } 

     }); 
    } 

回答

2

fiddle,只需更换

$(this) 

cell 

你确保你指向正确的元素

0

您应该运行在鼠标悬停查询。现在,您在绘制表格后立即运行单元格查询。