Home  >  Article  >  Web Front-end  >  How jQuery implements the CheckBox method of two columns in a table to select only one method

How jQuery implements the CheckBox method of two columns in a table to select only one method

小云云
小云云Original
2017-12-27 11:02:531751browse

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!

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