How to prevent buttons from submitting forms

后端 未结 17 2114
礼貌的吻别
礼貌的吻别 2020-11-21 04:43

In the following page, with Firefox the remove button submits the form, but the add button does not.

How do I prevent the remove button from submitting t

17条回答
  •  渐次进展
    2020-11-21 05:21

    Here's a simple approach:

    $('.mybutton').click(function(){
    
        /* Perform some button action ... */
        alert("I don't like it when you press my button!");
    
        /* Then, the most important part ... */
        return false;
    
    });
    

提交回复
热议问题