Home >Web Front-end >JS Tutorial >jQuery implements an example of how only one of two column CheckBoxes in a table can be selected

jQuery implements an example of how only one of two column CheckBoxes in a table can be selected

韦小宝
韦小宝Original
2018-01-15 11:37:321771browse

The following editor will bring you an example of jQuery realizing that only one of the two columns of CheckBox in the table can be selected. The editor thinks it’s pretty good, so I’ll share it with everyone in the jquery source code now, and give it as a reference for everyone. If you are interested in jquery, please follow the editor to have a look

//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=&#39;checkbox&#39;]").removeAttr("checked");
  });

})
</script>


//Renderings, temporarilycannot be uploadeddynamic ones, personal testing is useful

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. Oh~

Related recommendations:

detailed explanation of jQuery Ajax method for uploading files

jQuerylayui common method examples sharing

Introduction to common methods of jQuery layui

The above is the detailed content of jQuery implements an example of how only one of two column CheckBoxes in a table can be selected. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn