Home  >  Article  >  Web Front-end  >  jquery realizes the function of changing color when clicking the corresponding row in the table

jquery realizes the function of changing color when clicking the corresponding row in the table

WBOY
WBOYOriginal
2016-05-16 09:00:183309browse

for a table, in order to make our selected items easier to distinguish, we need to add highlighting and remove the highlighting of other items as needed. similar to:

html>
    <meta>
    <title></title>
    <link>
    <script></script>
    <script>
        $(function () {
            $('tbody>tr').click(function () {
                $(this).addClass('selected')      //为选中项添加高亮
                .siblings().removeClass('selected')//去除其他项的高亮形式
                .end();
            });
        }); 
    </script>
    
                                                                                                                      
姓名 性别 暂住地
张三 浙江宁波
张三 浙江宁波
张三 浙江宁波
张三 浙江宁波
张三 浙江宁波

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn