DEV Community

Falah Al Fitri
Falah Al Fitri

Posted on • Updated on

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

Top comments (0)