I’m trying to click on a link using jquery. There only appears to be a click event that replicates ‘onclick’ (i.e user input). Is it possible to use jquery to actually click a link?
Share
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.
From your answer:
is not a valid selector. to get the first a on the page use:
or
So for the selector in your answer:
write
Note how this will click all the links in the second table cell of the second table row in the second table on your page.
If you use this method to redirect the page to the href of the a the following method is slightly nicer:
Note how this will set the document location to the href of the first a found in the second table cell of the second table row found in the second table on the page.
If you want to match the first elements use eq(0) instead of eq(1).
EDIT
If you really want to do this 1337-haxxor
however I think the other method is more readible.
EDIT
Okay, from you next answer/question thingie
How about not actually clicking on the link but just setting the document.location string to it: