Highlighting the clicked row of a striped HTML table

后端 未结 5 1786
夕颜
夕颜 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:50

    It is much easier, just use de Bootstrap css classes (like .info .warning .error or .success) to switch between the selected row and not selected. They have all the states for the row.

    I used this, based on @iambriansreed answer:

    $('#mytable tbody tr').live('click', function(event) {
        $(this).addClass('info').siblings().removeClass('info');
    }
    

提交回复
热议问题