Home > Web Front-end > JS Tutorial > The jQuery code that can only select one of the two column CheckBoxes in the table

The jQuery code that can only select one of the two column CheckBoxes in the table

小云云
Release: 2018-02-03 11:35:27
Original
1976 people have browsed it

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>
Copy after login

//jQuery

<script type="text/javascript">

$(function(){


  $("#unit tr").click(function () {
    $(this).siblings().find("input[type='checkbox']").removeAttr("checked");
  });

})
</script>
Copy after login

//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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template