Home > Web Front-end > JS Tutorial > 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
Release: 2018-09-27 11:32:17
Original
3363 people have browsed it

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>
    
Copy after login
                                                                                                                      
姓名 性别 暂住地
张三 浙江宁波
张三 浙江宁波
张三 浙江宁波
张三 浙江宁波
张三 浙江宁波

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template