1. Create a new document (using NotePad software. In order to make it not garbled to open in the browser, find the encoding in the software file and modify it to UTF-8 encoding. Or click on the three bars in the upper right corner of Google Chrome, select More Tools -> Encoding -> UTF-8), and rename it (Example: the first java script.html Note: Be sure to change the extension to .html).
2. Open it in Notepad format and write it.
3. The following is the relevant code for "Implementation of All Buttons" written:
<html><head><title> Implementation of Select All Button</title></head><body><div><input type="checkbox" id="chkAll" onclick="checkAll(this)" />Select all</div><div><input type="checkbox" name="chk"/>Option 1</div><div><input type="checkbox" name="chk"/>Option 2</div><div><input type="checkbox" name="chk"/>Option 3</div><div><input type="checkbox" name="chk"/>Option 4</div><input type="checkbox" name="chk"/>Option 5</div></body><script>//Select all function checkAll(e){var t=document.getElementsByName("chk");alert(t.length);for(var i=0;i<t.length;i++){t[i].checked=document.getElementById("chkAll").checked;}}</script></html>4. Screenshot is: