Home >Web Front-end >JS Tutorial >How jQuery implements the CheckBox method of two columns in a table to select only one method
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’s pretty good, so I’ll share it with you now and give it as a reference. 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 for the time being. I will test the useful ones
The above is the entire content of the jQuery implementation example where only one of the two column CheckBoxes in the table can be selected by the editor. I hope you like it~
Related recommendations:
Example explains how jQuery implements the checkbox instant modification and batch deletion function
Example explains how jQuery implements the simple operation of checkbox
jQuery operation checkbox to achieve multiple selection and deselection examples
The above is the detailed content of How jQuery implements the CheckBox method of two columns in a table to select only one method. For more information, please follow other related articles on the PHP Chinese website!