I did everything I could to alert something after submitting a button which has been created in runtime, I gained no success. The code is simple so I don’t post here.
Is there problem with runtime buttons that can’t accept submit event?
$(".simple_btn").click(function(e){
$("this").submit(function(){
return false;
});
});
The
.submitevent applies to forms not buttons. So instead of:you probably want:
And as far as subscribing to events such as submit to dynamically added elements (that would be a
<form>in your case) you could use the.on()method if you are using jQuery 1.7 or the.delegate()method if you are using an older version.And here’s a live demo in which we use the
.on()method to subscribe to the submit event of a form that is dynamically added to the DOM at a later stage.