开发者

problem with jquery live submit

开发者 https://www.devze.com 2023-02-18 20:42 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号