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 so I need to target a specific submit button.
How could I do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you know the number of
submitinputs and which one (in order) you want to trigger aclickon then you can usenth-child()syntax to target it. Or add an ID or a class to each one that separates them from the other.Selecting the elements by their index:
There are actually several ways to do this including using
.eq(): http://api.jquery.com/eqSelecting the elements by their id:
Note that
.click()is short for.trigger('click').