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
Preface The service has been deployed on MySQL fo...
This article shares the specific code for impleme...
Table of contents Overview 1. Global Registration...
At first, I wanted to modify the browser scroll b...
Today I wanted to change the mysql port, but I fo...
1. Download Go to the Apache official website htt...
Generally, after there is a menu on the left, the...
What is margin-top collapse Margin-top collapse i...
Occasionally, I need to group select contents. In ...
Preface Slow query log is a very important functi...
Table of contents 1. Database Operation 2. Data T...
1. Download centos7 Download address: https://mir...
Table of contents Problem Description Front-end c...
If we want to make a carousel, we must first unde...
There are many XHTML tags: div, ul, li, dl, dt, d...