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

207
Views
Ocultar el contenido del formulario hasta que se haga clic en el botón

Me gustaría ocultar el contenido de mi formulario hasta que se haga clic en el botón, el código que estoy usando muestra el contenido hasta que se haga clic en él, estoy comenzando, así que probablemente me falta algo simple, se agradece cualquier ayuda, el código que estoy usando es:

 <script> function myFunction() { var x = document.getElementById("myDIV"); if (x.style.display === "block") { x.style.display = "none"; } else { x.style.display = "block"; } } </script>
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

debe agregar "display: none;" a la propiedad "myDiv" en el archivo css, entonces puede usar su func

about 4 years ago · Juan Pablo Isaza Report

0

Prueba esto :

 function myFunction() { var x = document.getElementById("myDIV"); if (x.style.display == "none" || x.style.display == "") { x.style.display = "block"; } else { x.style.display = "none"; } }
 #myDIV { border:solid 1px #c0c0c0; padding:10px; display:none; }
 <input type="button" onclick="myFunction();" value="switch" /><br> <div id="myDIV">Welcome</div>

Porque, si display está marcada en css a none (o lo que sea, pero no en el elemento DOM ), javascript lo "verá" como una cadena vacía. O configura en <div id="myDIV" style="display:none;"></div> . Según mi opinión, el primer código es una mejor opción.

about 4 years ago · Juan Pablo Isaza Report

0

Creo que esto es lo que necesitas Aquí está el código:

 document.getElementById("myButton").onclick = function() { document.getElementById("myInput").style.display = "block"; }
 <form> <input type="text" id="myInput" style="display: none;"> </form> <button id="myButton">Click</button>

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!