Click a specific submit button with JQuery

前端 未结 6 1355
温柔的废话
温柔的废话 2021-02-05 03:33

I am clicking a submit button using this:

$(\'input[type=submit]\').click(); 

The problem is that I have more that 1 submit button on my page s

6条回答
  •  天涯浪人
    2021-02-05 03:41

    If you add a marker, like a specific id or class to your input, you can make your selector more specific. For example, if you give the button you want the ID of form-btn like this:

    
    

    You can select it like this:

    $('input[type=submit]#form-btn').click();
    

    Or just:

    $('#form-btn').click();
    

提交回复
热议问题