当前位置:Gxlcms > JavaScript > jQuery实现table中两列CheckBox只能选中一个的示例

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

时间:2021-07-01 10:21:17 帮助过:40人阅读

下面小编就为大家带来一篇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>


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

以上就是小编为大家带来的jQuery实现table中两列CheckBox只能选中一个的示例的全部内容了,希望大家喜欢哦~

相关推荐:

jQuery Ajax方式上传文件详解

jQuerylayui常用方法实例分享

jQuery layui常用方法介绍

以上就是jQuery实现table中两列CheckBox只能选中一个的示例的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行