码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2017-09-21 19:40:45      阅读:661      评论:0      收藏:0      [点我收藏+]

标签:ble   check   有用   find   com   box   bsp   效果   alt   

//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只能选中一个

标签:ble   check   有用   find   com   box   bsp   效果   alt   

原文地址:http://www.cnblogs.com/xuelishuyue/p/7569806.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!