I am trying to bind this submit event from a form which not always be in Dom, so I trying with .on()
:
$('body').on("form","submit", function(e){})
but firebug logs:
$("body").on is not a function
[Parar en este error]$('body').on("form","submit", function(e){
tried also
$(document).on("form","submit", function(e){})
If you are upgrading to jQuery 1.7, you can use on() by applying form
as a selector, like:
$('body').on("submit", "form", function(e){
Which will bind the submit
event to body
, but filtering it to form
which works the same way as the delegate
example below.
If you are using 1.4.2 or newer, you can use delegate() like this:
$('body').delegate("form", "submit", function(e){
You have to select the form and use on
to bind the event listener.
$( "form" ).on( "submit", function(e){} );
You also need jQuery version 1.7 or higher to use on
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.