I have a code the change the html of a div to make a button. When I make a click handler for the dynamic button, nothing happens
$('#signinup').html("<button id=\"login_submit\">Sign In</button>");
And the handler:
$('#login_submit').click(function() {
alert("Works!");
});
See the working demo 🙂
Use the
live()method:The
live()method attach a handler to the event for all elements which match the current selector, now or in the future.