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

125
Views
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 answers
Answer question

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 Report

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 Report

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 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!