tr background color

tr background color

michelekmichelek Posts: 24Questions: 5Answers: 0

I need to change the background color of the selected table but does not work me??

('#documenti_g tbody').on( 'click', 'tr', function () {

 var row = $(this).index()+1;
 $(row).css('background-color', '#000');
           
} );

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    $(row)

    Is that not going to resolve to be something like $(4) in the above code? I'm not entirely sure I understand what the goal there is. If you want to change the background of the whole table as your comment suggests, use $(this).closest('table').css( ... ).

    Allan

This discussion has been closed.