Change tr background-color

后端 未结 7 1419
刺人心
刺人心 2021-02-04 04:36

I have something like this:

\' onclick=\"SetBackgroundColor(this)\" style=\"background-color:Yellow\">

Whe

7条回答
  •  南方客
    南方客 (楼主)
    2021-02-04 05:18

    A simpler solution is to probably use a selector for all rows in the table or addClass.

    Example

    $("#myTable tr").click(function() {
        $(this).css('background-color', '#f00');
    });
    

    or

    $("#myTable tr").click(function() {
        $(this).addClass('selected');
    });
    

提交回复
热议问题