This article mainly brings you an example of how jQuery can only select one of the two columns of CheckBox in the table. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor to take a look, I hope it can help everyone.
//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>
//The renderings cannot be uploaded temporarily, but they are useful for personal testing
Related recommendations:
How to beautify the style of HTML checkbox and radio
##How to expand the click range of input checkbox
jQuery implements checkbox method
The above is the detailed content of The jQuery code that can only select one of the two column CheckBoxes in the table. For more information, please follow other related articles on the PHP Chinese website!