zoukankan      html  css  js  c++  java
  • 列表中被点击的行加亮背景色

    <!doctype html>
    <html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>列表中被点击的行加高亮背景色</title>
        <meta name="keywords" content="" />
        <meta name="description" content="" />        
        <script type="text/javascript" src="../jquery-1.8.2.js"></script>
        <script type="text/javascript">
        //点击某行后,高亮点中行的样式
        function heightBrightTR(thisObj){        
           var thisTD = $(thisObj).parent();    //<a> 链接所在上层单元格td对象
            var thisTR = thisTD.parent();        //<a> 链接所在上层行tr对象    
            thisTR.addClass('trBgStyle');                    //添加背景高亮色
            thisTR.siblings('tr').removeClass('trBgStyle'); //将同级同胞的背景色置空
        }
        </script>
        <style type="text/css">
         .trBgStyle{background:#ffff66;}   /* 用于点击后改变行背景色 */
        </style>
    </head>
    <body>
        <table border="1" width="100%" cellspacing="0" cellpadding="0">
            <tr>
                <th>id号</th>
                <th>链接地址</th>
            </tr>
            <tr>
                <td>2</td>
                <td><a onclick="heightBrightTR(this)" target="_blank" href="http://www.google.com.hk">Google</a></td>
            </tr>
            <tr>
                <td>1</td>
                <td><a onclick="heightBrightTR(this)" target="_blank" href="http://www.baidu.com">百度</a></td>
            </tr> 
            <tr>
                <td>4</td>
                <td><a onclick="heightBrightTR(this)" target="_blank" href="http://cn.msn.com">MSN中文网</a></td>
            </tr>       
        </table>
    
    
    
    
    </body>
    </html>
  • 相关阅读:
    币值转换
    第八周作业
    第七周作业
    第五周编程总结
    第四周编程总结
    第三周编程总结
    7-1 查找整数
    7-2 求最大值及其下标
    秋季学习总结
    对我影响最大的三个老师
  • 原文地址:https://www.cnblogs.com/martinzhang/p/3302163.html
Copyright © 2011-2022 走看看