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

182
Views
Trabajando localmente. Pero cuando uso el paquete index.html no es

Tengo una página de precios donde puedo cambiar entre anual y mensual. Al final, estoy vinculando a un archivo js como este.

 <div class="top"> <div class="toggle-btn"> <span style="margin: 0.8em;">Annually</span> <label class="switch"> <input type="checkbox" id="checbox" onclick="check()" ; /> <span class="slider round"></span> </label> <span style="margin: 0.8em;">Monthly</span></div> </div> <header><h2><em>Hobbyist</em></h2> <p class="pricing text1">$2 per month</p> <p class="pricing text2">$1 per month billed yearly</p> </header> <script src="js/pricing.js"></script> <script src="js/main.js"></script>

Y el precio js se ve así

 function check() { var checkBox = document.getElementById("checbox"); var text1 = document.getElementsByClassName("text1"); var text2 = document.getElementsByClassName("text2"); for (var i = 0; i < text1.length; i++) { if (checkBox.checked == true) { text1[i].style.display = "block"; text2[i].style.display = "none"; } else if (checkBox.checked == false) { text1[i].style.display = "none"; text2[i].style.display = "block"; } } }

Recibo un error en la consola como resultado de que la palanca se mueve pero no activa la función javascript requerida que hace que el precio se mueva entre $ 1 y $ 2 dólares. ¿Puede alguien sugerirme cómo solucionar esto? Soy bastante nuevo en la programación.

Error

 Uncaught ReferenceError: check is not defined at HTMLInputElement.onclick ((index):74:74)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

 Pricing.js function check() { var checkBox = document.getElementById("checbox"); var text1 = document.getElementsByClassName("text1"); var text2 = document.getElementsByClassName("text2"); for (var i = 0; i < text1.length; i++) { if (checkBox.checked == true) { text1[i].style.display = "block"; text2[i].style.display = "none"; } else if (checkBox.checked == false) { text1[i].style.display = "none"; text2[i].style.display = "block"; } } }
 <!DOCTYPE html> <html> <head> <script src="pricing.js"></script> </head> <body> <div class="top"> <div class="toggle-btn"> <span style="margin: 0.8em;">Annually</span> <label class="switch"> <input type="checkbox" id="checbox" onclick="check()" ; /> <span class="slider round"></span> </label> <span style="margin: 0.8em;">Monthly</span></div> </div> </body> </html>

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!