Highlighting the clicked row of a striped HTML table

后端 未结 5 1791
夕颜
夕颜 2020-12-12 21:54

Here\'s an example of my problem on jsFiddle.

I have a table with striped rows imposed by using tr:nth-child(odd) in the CSS, as is done in Twitter Boot

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 22:46

    As far as I understand:

    $('#mytable tbody tr').live('click', function(event) {
        $clicked_tr = $(this);
        $('#mytable tbody tr').removeClass("highlight");
        $clicked_tr.addClass('highlight');
    });​
    

提交回复
热议问题