Using JQuery - preventing form from submitting

后端 未结 13 3083
灰色年华
灰色年华 2020-11-22 06:51

How do I prevent a form from submitting using jquery?

I tried everything - see 3 different options I tried below, but it all won\'t work:

    $(docu         


        
13条回答
  •  被撕碎了的回忆
    2020-11-22 07:20

    I had the same problem and I solved this way (not elegant but it works):

    $('#form').attr('onsubmit','return false;');
    

    And it has the advantage, in my opinion, that you can revert the situation any time you want:

    $('#form').attr('onsubmit','return true;');
    

提交回复
热议问题