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

129
Views
cómo mantener la casilla de verificación marcada usando javascript

 function check() { if (document.getElementById("myCheck").checked == true) { document.getElementById("myCheck").checked = true; } }
 <!DOCTYPE html> <html> <body> Checkbox: <input type="checkbox" id="myCheck" onclick="check()"> </body> </html>

Descripción

  1. Aquí he estado tratando de mantener marcada la casilla de verificación si la casilla de verificación ya está marcada.
  2. Traté de verificar con el estado de la casilla de verificación que si la casilla de verificación está marcada, entonces establezco la casilla marcada como 'verdadero'.
  3. Pero sigue desmarcando la casilla de verificación si la casilla de verificación está marcada.

Qué necesito

  1. Necesito mantener la casilla de verificación marcada si ya está marcada. Sugiera solo javascript.
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Puede eliminar la condición if (document.getElementById("myCheck").checked == true) si desea mantenerla marcada una vez que se haya verificado por primera vez.

 function check() { document.getElementById("myCheck").checked = true; }
 <!DOCTYPE html> <html> <body> Checkbox: <input type="checkbox" id="myCheck" onclick="check()"> </body> </html>

about 4 years ago · Juan Pablo Isaza Report

0

Desactive la casilla de verificación después de haberla hecho clic una vez.

 document.getElementById("myCheck").disabled = true;
about 4 years ago · Juan Pablo Isaza Report

0

con entradas usamos onchange

 const checkbox = document.getElementById('my-checkbox') checkbox.checked = true checkbox.onchange = function() { checkbox.checked = true }
about 4 years ago · Juan Pablo Isaza Report
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!