<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> </head> <body> <input type="checkbox" name="" id="" class="delete_checkbox"> </br> <input type="checkbox" name="nan" id="" class="delete_checkbox"></br> <input type="checkbox" name="nan" id="" class="delete_checkbox"></br> <input type="checkbox" name="nan" id="" class="delete_checkbox"></br> <input type="checkbox" name="nan" id="" class="delete_checkbox"></br> <script type="text/javascript"> let delete_checkbox = document.getElementsByClassName('delete_checkbox')[0]; let arr = true; delete_checkbox.addEventListener('click', function() { let nan = document.getElementsByName('nan') for (let i = 0; i < nan.length; i++) { nan[i].checked = this.checked; } }) </script> </body> </html>