Prevent submit button with onclick event from submitting

后端 未结 5 1671
一向
一向 2020-12-17 10:21

I want to prevent a submit button with onclick event from submitting:

$j(\'form#userForm .button\').click(function(e) {
    if ($j(\"#zip_field\").val() >         


        
5条回答
  •  我在风中等你
    2020-12-17 10:51

    Don't forget that there are function/event arguments, but you must specify the parameters:

    $("#thing").click(function(e) {
      e.preventDefault();
    });
    

    In this way, the submission is halted, and so you can conditionalise it.

提交回复
热议问题