How to prevent buttons from submitting forms

后端 未结 17 2063
礼貌的吻别
礼貌的吻别 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:35

    The function removeItem actually contains an error, which makes the form button do it's default behaviour (submitting the form). The javascript error console will usually give a pointer in this case.

    Check out the function removeItem in the javascript part:

    The line:

    rows[rows.length-1].html('');
    

    doesn't work. Try this instead:

    rows.eq(rows.length-1).html('');
    

提交回复
热议问题