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
This article summarizes the notes for installing ...
Installing XML extension in PHP Linux 1. Enter th...
FOUC is Flash of Unstyled Content, abbreviated as ...
Table of contents 1. Introduction to Harbor 1. Ha...
[LeetCode] 197.Rising Temperature Given a Weather...
Table of contents Separation effect Command line ...
In the process of web front-end development, UI d...
Preface For production VPS with public IP, only t...
<br />Most of the time when we talk about na...
Table of contents 1.1. Network access between con...
In MySQL, we usually use limit to complete the pa...
1. Requirements: Database backup is particularly ...
1. Introduction It has been supported since versi...
JavaScript shows and hides pictures, for your ref...
1 Effect Demo address: https://www.albertyy.com/2...