欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery實(shí)現(xiàn)控制表格行高亮實(shí)例

 更新時(shí)間:2013年06月05日 10:03:21   作者:  
jquery實(shí)現(xiàn)控制表格行高亮實(shí)例,需要的朋友可以參考一下

[css]

復(fù)制代碼 代碼如下:

<style>
.height{
  background:#666666;   /*背景顏色為灰色*/
}
tr{
    cursor: pointer;    /*手形*/  
}
</style>

<style>
.height{
  background:#666666;   /*背景顏色為灰色*/
}
tr{
 cursor: pointer;    /*手形*/
}
</style>


[html] 
復(fù)制代碼 代碼如下:

<body>
<table border="1" width="40%">
   <tr><th></th><th align="left">姓名</th><th align="left">性別</th><th align="left">居住地</th></tr>
   <tr>
        <td><input type="radio" name="radio" /></td><td>張三</td><td>男</td><td>北京</td>
   </tr>
    <tr>
        <td><input type="radio" name="radio" /></td><td>李四</td><td>男</td><td>上海</td>
   </tr>
    <tr>
        <td><input type="radio" name="radio" /></td><td>王五</td><td>女</td><td>深圳</td>
   </tr>
    <tr>
        <td><input type="radio" name="radio" /></td><td>趙六</td><td>女</td><td>北京</td>
   </tr>
    <tr>
        <td><input type="radio" name="radio" /></td><td>孫七</td><td>男</td><td>上海</td>
   </tr>
</table>
</body>

<body>
<table border="1" width="40%">
   <tr><th></th><th align="left">姓名</th><th align="left">性別</th><th align="left">居住地</th></tr>
   <tr>
        <td><input type="radio" name="radio" /></td><td>張三</td><td>男</td><td>北京</td>
   </tr>
    <tr>
        <td><input type="radio" name="radio" /></td><td>李四</td><td>男</td><td>上海</td>
   </tr>
    <tr>
        <td><input type="radio" name="radio" /></td><td>王五</td><td>女</td><td>深圳</td>
   </tr>
    <tr>
        <td><input type="radio" name="radio" /></td><td>趙六</td><td>女</td><td>北京</td>
   </tr>
    <tr>
        <td><input type="radio" name="radio" /></td><td>孫七</td><td>男</td><td>上海</td>
   </tr>
</table>
</body>


jquery

[javascript]

復(fù)制代碼 代碼如下:

 plaincopyprint?$(document).ready(function(){
       //第一種寫法: $("tr:gt(0)")   第一行標(biāo)題不起作用  
       $("tr:gt(0)").click(function(){
              $(this).addClass("height").siblings().removeClass("height").end().find(":radio").attr("checked",true);
       })

       //第二種寫法:$("tr:not(:first)") 
       /*$("tr:not(:first)").click(function(){
              $(this).addClass("height").siblings().removeClass("height").end().find(":radio").attr("checked",true);
       })*/
})

$(document).ready(function(){
    //第一種寫法: $("tr:gt(0)")   第一行標(biāo)題不起作用
    $("tr:gt(0)").click(function(){
     $(this).addClass("height").siblings().removeClass("height").end().find(":radio").attr("checked",true);
    })

    //第二種寫法:$("tr:not(:first)")
    /*$("tr:not(:first)").click(function(){
     $(this).addClass("height").siblings().removeClass("height").end().find(":radio").attr("checked",true);
    })*/
})

相關(guān)文章

最新評(píng)論