你的位置:首页 > 软件开发 > 网页设计 > jQuery实现table中两列CheckBox只能选中一个

jQuery实现table中两列CheckBox只能选中一个

发布时间:2017-09-21 18:00:17
//html<table id="unit"> <tr> <th>选项一</th> <th>选项二</th> <th>姓名</th> </tr> ...

//html

<table id="unit">
<tr>
<th>选项一</th>
<th>选项二</th>
<th>姓名</th>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td><input type="checkbox" /></td>
<td>小红</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td><input type="checkbox" /></td>
<td>小明</td>
</tr>
</table>

//jQuery

<script type="text/javascript">

$(function(){


  $("#unit tr").click(function () {
    $(this).siblings().find("input[type='checkbox']").removeAttr("checked");
  });

})
</script>

//效果图,暂时上传不了动态的,亲测有用的

jQuery实现table中两列CheckBox只能选中一个

 

原标题:jQuery实现table中两列CheckBox只能选中一个

关键词:jquery

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录