Javascript override form onsubmit event not working

前端 未结 4 1323
粉色の甜心
粉色の甜心 2021-01-12 20:20

I am overriding a form submit event like this:

form.onsubmit = function(event) {
  event.preventDefault();

But when I call submit on the fo

4条回答
  •  礼貌的吻别
    2021-01-12 20:55

    Following on @garryp's answer on "return false". To add on, further reading from MDN event.stopImmediatePropagation to see differences and use case between event.preventDefault and event.stopPropagation.

    On the side note, "return false;" is the same calling both;

      event.preventDefault();
      event.stopPropagation();
    

    Hope this helps.

提交回复
热议问题