I have a page that has a button on it. When the user clicks the button it dynamically render’s a form (ie it’s not just showing a hidden form.. it’s completely creating it using jQuery).
My issue is the newly created form doesn’t respond to any jQuery commands. This is the code I have for the rendered form at the moment.
$("#savenewlang").click(function(e) {
console.log("savenewlang has been clicked");
});
So it should just console.log when they click the submit button but it’s not running.
Any idea how to reload the DOM or assign that an actual event that correctly fires?
Here
#containerpoints to a parent element of#savenewlangthat belongs to DOM at page load.To specify this event
.on()you need three argumentsBut for ordinary binding it only needs two arguments
Read more about
.on()Remainder
Put all of your code within
in short