user2119324 user2119324 - 6 months ago 100
jQuery Question

How can I change the background color in a specific row of jQuery jTable?

rowInserted: function (event, data) {
if (data.record) {
if (condition1 == condition2) {
$('#div1').find(".jtable tbody tr").css("background", "#F5ECCE");
}
}
}


the above code could be changing all row color, can i specify row number?

Answer

Use :eq() selector like,

rowInserted: function (event, data) {
   if (data.record) {
       if (condition1 == condition2) {
          $('#div1').find(".jtable tbody tr:eq(1)").css("background", "#F5ECCE");
          // changing first row background color
       }
   }
}

Updated you can set index dynamically like

$('#div1').find(".jtable tbody tr:eq("+index+")").css("background", "#F5ECCE");