您好,欢迎来到微智科技网。
搜索
您的当前位置:首页jQuery实现table中两列CheckBox只能选中一个的示例

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

来源:微智科技网
 下面小编就为大家带来一篇jQuery实现table中两列CheckBox只能选中一个的示例。小编觉得挺不错的,现在就分享给jquery源码大家,也给大家做个参考。对jquery感兴趣的一起跟随小编过来看看吧

//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>

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

Copyright © 2019- 7swz.com 版权所有 赣ICP备2024042798号-8

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务