Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 923
user2119324 Avatar asked Dec 16 '22 05:12

user2119324


1 Answers

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");
like image 179
Rohan Kumar Avatar answered Jan 26 '23 00:01

Rohan Kumar