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

172
Views
¿Cómo dejar de mostrar la página web después de ingresar respuestas incorrectas?

Tengo una página web, al cargar la página hace algunas preguntas si todas las preguntas son correctas solo luego muestra la parte del cuerpo; de lo contrario, la pregunta no permitirá la siguiente pregunta o no debería mostrar la parte del cuerpo, ayúdenme a solucionar este problema. ...

 <!DOCTYPE html> <html> <head> <title>Special-Wishes </title> <script> let q1=prompt("what is your name...?"); //if the q1 answer is wrong it should not display the body content if(q1 == "John" || "JOHN" ){ let q2=prompt("what's your nick name...?"); if(q2=="blabla"){ alert("welcome to the page"); } } </script> </head> <body> <h1>My body section</h1> </body>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

La razón por la que todavía está haciendo la siguiente pregunta se debe a la lógica de su declaración if
if(q1 == "John" || "JOHN" ) debería ser if(q1 == "John" || q1 == "JOHN" )

Una forma aún más fácil de hacer esto sería if(q1.toUpperCase() == "JOHN")

Para no mostrar el cuerpo, desea eliminarlo o ocultarlo. Esto se puede hacer en un bloque else después de su declaración if

Eliminar: document.body.remove();
Ocultar: document.body.style.display = "none";

about 4 years ago · Juan Pablo Isaza Report

0

Use document.body.style.display = "none" cuando la condición no coincida

 let q1 = prompt("what is your name...?"); //if the q1 answer is wrong it should not display the body content if (q1 == "John") { let q2 = prompt("what's your nick name...?"); if (q2 == "blabla") { alert("welcome to the page"); } else { document.body.style.display = "none" } } else { document.body.style.display = "none" }
 <body> <h1>My body section</h1> </body>

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!