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

65
Views
How to click a printed button in JQuery

I have a button "Confirm" that is being printed by Javascript, i want to do something after user click this button (for example an alert), but when i try to use on click event nothing happens. How can i do?

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    document.getElementById("par_2").innerHTML = '<button id="btn" type="submit">Confirm</button>'
  });
  
  $("#btn").on('click',function(e){
        alert("Hello");
  });
});
</script>
</head>
<body>

<h2>This is a heading</h2>

<p>This is a paragraph.</p>
<p id="par_2">This is another paragraph.</p>

<button>Click me</button>

</body>
</html>

I simplified my problem. My real problem is to submit a printed form...

about 4 years ago · Santiago Trujillo
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!