jquerycssjquery-jtable

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?


Solution

  • 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");