This article shares the specific code for JavaScript to implement the select all and unselect all operations for your reference. The specific content is as follows Effect examplesBy default: When Select All is checked: When you uncheck item A/item B/item C at will Implementation Code<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Select All</title> <script> function myAll() { var all = document.getElementById("all"); var oneList = document.getElementsByName("one"); for(var i = 0; i < oneList.length; i++) { oneList[i].checked = all.checked; } } function myOne() { var all = document.getElementById("all"); var oneList = document.getElementsByName("one"); for(var i = 0; i < oneList.length; i++) { if(oneList[i].checked == false) { all.checked = false; return; } } all.checked = true; } </script> </head> <body> <table id="myTable" border="1" cellpadding="0" cellspacing="0" width="90%" height="180px"> <tr> <th>Select All<input id="all" type="checkbox" onclick="myAll()" /></th> <th>Serial number</th> <th>Name</th> <th>Unit Price</th> <th>Quantity</th> <th>Total</th> </tr> <tr> <td><input name="one" type="checkbox" onclick="myOne()" /></td> <td>1</td> <td>Item A</td> <td>¥55</td> <td>1</td> <td>¥55</td> </tr> <tr> <td><input name="one" type="checkbox" onclick="myOne()" /></td> <td>2</td> <td>Item B</td> <td>¥70</td> <td>1</td> <td>¥70</td> </tr> <tr> <td><input name="one" type="checkbox" onclick="myOne()" /></td> <td>3</td> <td>Item C</td> <td>¥66</td> <td>1</td> <td>¥66</td> </tr> </table> </body> </html> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
>>: Quickly learn MySQL basics
Table of contents 1. Generate a certificate 2. En...
1. Linux kernel driver module mechanism Static lo...
Preface When using Docker in a production environ...
This article uses an example to describe how to c...
Preface As you all know, we have encountered many...
This article shares a native JS implementation of...
Table of contents 1. Basics 2. Nodes, trees, and ...
Original Intention The reason for making this too...
(I) Basic concepts of web page color matching (1) ...
Introduction to Debian Debian in a broad sense re...
These introduced HTML tags do not necessarily ful...
transform: scale(); Scaling will cause jitter in ...
Table of contents 1. Overview 2. nginx.conf 1) Co...
Pull the image: [mall@VM_0_7_centos ~]$ sudo dock...
Table of contents 1. Reduce the number of image l...