Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda