zoukankan      html  css  js  c++  java
  • jquery实现表格中点击相应行变色功能

    对于一个表格,为了使我们选中的项更容易区分,需要为选中项添加高亮,同时也需要,将其他项的高亮形式去除。类似于:

    复制代码
    <!DOCTYPE html>
    
    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="utf-8" />
        <title></title>
        <link href="css/style.css" rel="stylesheet" type="text/css" />
        <script src="jquery-1.3.2.min.js"></script>
    <style>

    .selected{
    background-color :blueviolet;
    }


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

    --------------------- 本文来自 JsonZhang_ZY 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/zhang_yang_43/article/details/51344177?utm_source=copy 

  • 相关阅读:
    day13—— luffy项目 User表的配置
    day13 —— luffy项目 数据库配置
    day13- luffy项目 后端搭建
    Vue环境搭建
    Python创建虚拟环境
    pip换源
    day12--DRF 进阶7 JWT补充、基于权限的角色控制、django缓存
    C语言输出格式总结-printf()
    PAT 甲级 1108 Finding Average (20分)
    DAY30
  • 原文地址:https://www.cnblogs.com/asdyzh/p/9743763.html
Copyright © 2011-2022 走看看