jQuery如何实现table中两列CheckBox只能选中一个
这篇文章将为大家详细讲解有关jQuery如何实现table中两列CheckBox只能选中一个,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
//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只能选中一个”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。