Change tr background-color

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

I have something like this:

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

Whe

7条回答
  •  醉酒成梦
    2021-02-04 05:04

    In jQuery you do not have to use the onclick attribute to assign an event handler. Lets say you add a class called mytr to each tr that you want to affect. Then you can do something like this:

     $(document).ready(function(){
            $(".mytr").click(function(){
                 $(this).css("background-color", "#000000");
            });
     });
    

    And that will apply the event handler to all rows with the class mytr.

提交回复
热议问题