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

271
Views
how to create a text box when button is pressed in Js?

I want to create a button in JS and when you press it, it will create a text box above the button. But the number of textboxes is unknown. is it possible? Thank you

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can do it like this:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Ronak</title>
</head>
<body>
  <div id="textboxContainer">
  </div>
  <button onclick="addTextbox(event)">Click Me!</button>
  
  <script type="text/javascript">
    function addTextbox(event) {
          var input = document.createElement("input");
          input.setAttribute("type", "text");
          document.getElementById("textboxContainer").appendChild(input);
    }
  </script>
</body>
</html>

about 4 years ago · Juan Pablo Isaza Report

0

There are one way. You have to append it. With Jquery it is something like this:

<html>
<body>
    <button></button>
    <p id="new"></p>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>    
$("button").click(()=>{
    $("p#new").append("Your input textbox<input ---/>")
    })
</script>
</body>
</html>
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!