I am trying to bind the submit function to a number of forms in my page, but the problem is they still keep submitting the form!
I tried these:
$(".toggle-fo开发者_开发问答rm-submit").parents("form").live("submit", function(e){
var myForm = $(this);
console.log(myForm);
e.preventDefault();
return false;
});
SUBMITS FORM
live("submit"...
livequery("submit"...
WORKS AS INTENDED
submit(function()...
why doesn't it work if it is live or even livequery?
From the documentation:
DOM traversal methods are not supported for finding elements to send to
.live()
. Rather, the.live()
method should always be called directly after a selector, as in the example above.
So you need a selector that selects those forms, using parents()
won't work.
精彩评论