Submit Multiple Forms With One Button

后端 未结 4 1944
一个人的身影
一个人的身影 2020-12-02 00:31

I am using $_SESSION to dynamically create forms for my web store. These forms hold the custom info for the product that the customer wants. This is the layout:

4条回答
  •  余生分开走
    2020-12-02 01:15

    Here is a working jsFiddle: http://jsfiddle.net/SqF6Z/3/

    Basically, add a class to each form and trigger() a submit on that class. Like so:

    HTML (example only):

    jQuery:

    $('.myForms').submit(function () {
        console.log("");
        return true;
    })
    
    $("#clickMe").click(function () {
        $(".myForms").trigger('submit'); // should show 3 alerts (one for each form submission)
    });
    

提交回复
热议问题