Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

126
Vistas
Show input only after button press

I want to hide the <input> from the home page, I only want the input to display when I press the button.

I was making a typing game. I added an input field for mobile users, but I only want it to show if the button is clicked.

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Assuming you have the ID of the button and the input, you can do the following:

const button = document.querySelector("#button")
const input = document.querySelector("#input");

button.addEventListener("click", () => input.style.display = "block");

Please note that the input should be with a display: none; CSS property first.

about 4 years ago · Juan Pablo Isaza Denunciar

0

As I could see input fields are not hidden, so may want to hide them first. Example style="display:none". Then in your onclick add something like the following:

$("#buttonid").on("click", function(){
 $("#inputid").show();
about 4 years ago · Juan Pablo Isaza Denunciar

0

In html you need to have an <input> and <button>.

<input type="text" name="info" id="info" class="">
<button id="showInfo">Show Input</button>

In css add class .active and set on input display: none.

input {
   display: none;
}

.active {
   display: block;
}

First set is download from DOM <input> and <div>. The second step is add event listener for click event on the <button>.

const input = document.querySelector('input#info');
const showInput = document.querySelector('button#showInfo');

showInput.addEventListener('click', () => {
   input.classList.toggle('active')
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda