Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
un botón para marcar todas las casillas de verificación y desmarcarlas también

Tengo 3 casillas de verificación y un botón, así que cuando hago clic en este botón, todo debe estar marcado y si vuelvo a hacer clic, todo debe desmarcarse, pero no funciona. Quiero todas las funciones dentro de mi objeto de esta manera.

 btn: null, check: function(checked = true) { const checkboxes = document.querySelectorAll('input[name="cb"]'); checkboxes.forEach((checkbox) => { checkbox.checked = checked; }); }, checkAll: function() { this.check(); this.onclick = uncheckAll; }, uncheckAll: function() { this.check(false); this.onclick = checkAll; }, } btn.check();
 <body style="background-color: #0d1117; color: #6D859E"> <div style="margin: 60px;"> <button id="btn">Check / Uncheck All</button> <ul style="list-style-type: none; padding: 0"> <li> <label for="c1"><input type="checkbox" name="cb" value="1" id="c1">1</label> </li> <li> <label for="c2"><input type="checkbox" name="cb" value="2" id="c2">2</label> </li> <li> <label for="c3"> <input type="checkbox" name="cb" value="3" id="c3">3</label> </li> </ul> </div> </body>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!