javascript - jquery How to cancel the default event of form input submit and bind it to click event?
大家讲道理
大家讲道理 2017-05-19 10:34:03
0
5
1285

For someone else's form, how can I add a click event to its input submit type form button and prevent its default form from being submitted?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(5)
刘奇

You can replace input submit with button and bind click e.preventDefault();

伊谢尔伦

Hello, you can override the onclick event of the submit button and return false; after the meeting.
The following is part of the code, for reference only:

document.getElementById('submitButton').onclick = function() {
    // your code here...
    return false;
};
我想大声告诉你

Change the type of input to button, and then bind click.

淡淡烟草味

Not validating form when submitting it :

<form novalidate="novalidate">
阿神

You can return false when on submit, and then the submit button can be onclik

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template