Home  >  Article  >  Web Front-end  >  jquery implements select all and inverse single selection

jquery implements select all and inverse single selection

php中世界最好的语言
php中世界最好的语言Original
2018-04-19 16:33:212803browse

This time I will bring you jquery to realize the selection of all and reverse the selection of radio. What are the precautions for jquery to realize the selection of all and reverse the selection of radio. The following is a practical case. Let’s take a look.

jquery implements select all and inverse single selection

<linkrel="stylesheet"href="http://wiki.jikexueyuan.com/project/bootstrap4/dist/css/bootstrap.min.css"rel="external nofollow">
 <scriptsrc="https://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
 </script>
<tableclass="table table-bordered ">
 <theadclass="tab_head">
 <tr>
  <td> <inputtype="checkbox"onclick="selectAll()"></td>
  <th>角色名称</th>
  <th>角色说明</th>
  <th>所属系统</th>
 </tr>
 </thead>
 <tbody>
 <tr>
  <td> <inputtype="checkbox"></td>
  <td>系统管理员</td>
  <td>管理员角色</td>
  <td>武进公安平台</td>
 </tr>
 <tr>
  <td> <inputtype="checkbox"></td>
  <td>系统管理员</td>
  <td>管理员角色</td>
  <td>武进公安平台</td>
 </tr>
 <tr>
  <td> <inputtype="checkbox"></td>
  <td>系统管理员</td>
  <td>管理员角色</td>
  <td>武进公安平台</td>
 </tr>
 </tbody>
 </table>
 <script>
 function selectAll(){
 $("input[type=&#39;checkbox&#39;]").each( function() {
  if($(this).prop("checked")==true) {
  $("input[type=&#39;checkbox&#39;]").prop(&#39;checked&#39;, true);
  return;
  } else {
  $("input[type=&#39;checkbox&#39;]").prop(&#39;checked&#39;, false);
  return;
  }
 });
 }
 </script>

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

jQuery plug-in FusionCharts draws pie charts

jquery implements non-dynamic search

The above is the detailed content of jquery implements select all and inverse single selection. 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