简体   繁体   中英

Submit form using jquery with specific id

I am clicking a submit button using this:

Hlml :

<button type="submit" class="btn btn-submit">Submit</button>

Js :

$("#form_id").on('submit',(function(e) {

The problem is that I have more that 1 submit button on my form wizard so I need to target a specific submit button.

LIke

<button type="submit" id="submit_form" class="btn btn-submit">Submit</button>

How could I submit form using id="submit_form and $("#form_id") ?

You could attach click event to the button you want using the specific id attribute :

$("#form_id").on('click', '#submit_form', function(e) {
    e.preventDefault();

    //You logic here

   //Submit form at the end if you want
   //$("#form_id").submit();
});

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM