search

Home  >  Q&A  >  body text

javascript - jquery How to cancel the default event of form input submit and bind it to click event?

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?

大家讲道理大家讲道理2780 days ago1286

reply all(5)I'll reply

  • 怪我咯

    怪我咯2017-05-19 10:36:03

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

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-19 10:36:03

    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;
    };

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-19 10:36:03

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

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-19 10:36:03

    Not validating form when submitting it :

    <form novalidate="novalidate">

    reply
    0
  • 阿神

    阿神2017-05-19 10:36:03

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

    reply
    0
  • Cancelreply