DEV Community

Falah Al Fitri
Falah Al Fitri

Posted on • Edited on

1 1

jQuery Form multi submit preventDefault()


Happy Coding

https://stackoverflow.com/questions/11609295/jquery-submit-multiple-forms-in-a-page/59317426#59317426

/* get all form and loop */
$( "form" ).each( function () {

    /* addEventListener onsubmit each form */
    $( this ).bind( "submit", function (event) {

        /* return false */
        event.preventDefault();

        var form = event.target;

        /* display each props of forms */
        console.log( form ); // object formHTML
        console.log( "form id: " + form.id );
        console.log( "form action: " + form.action );
        console.log( "form method: " + form.method );

    } );

});
Enter fullscreen mode Exit fullscreen mode

Demo repl.it

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs