发布网友 发布时间:2024-10-22 22:44
共1个回答
热心网友 时间:2024-12-01 03:54
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
$(function(){
$("table tr").click(function(){
var input = $(this).find("input[type=checkbox]");//获取checkbox
//判断当前checkbox是否为选中状态
if(input.attr("checked")){
input.attr("checked",false);
}else{
input.attr("checked",true);
}
})
})
</script>
<table >
<thead>
<tr>
<td>选择</td>
<td>姓名</td>
<td>日期</td>
<td>金额</td>
<td>说明</td>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox"/></td>
<td>张三</td>
<td>2009-01-02</td>
<td>12.35</td>
<td>A股</td>
</tr>
<tr>
<td><input type="checkbox"/></td>
<td>张三</td>
<td>2009-02-02</td>
<td>122.35</td>
<td>B股</td>
</tr>
<tr>
<td><input type="checkbox"/></td>
<td>张三</td>
<td>2009-03-02</td>
<td>132.35</td>
<td>现金</td>
</tr>
<tr>
<td><input type="checkbox"/></td>
<td>张三</td>
<td>2009-04-02</td>
<td>142.35</td>
<td>港股</td>
</tr>
<tr>
<td><input type="checkbox"/></td>
<td>张三</td>
<td>2009-05-02</td>
<td>152.35</td>
<td>保险</td>
</tr>
<tr>
<td><input type="checkbox"/></td>
<td>张三</td>
<td>2009-06-02</td>
<td>162.35</td>
<td>基金</td>
</tr>
</tbody>
</table>