1

Today I'd try to click link using javascript. I don't know id, only class. Have u got any ideas ?

Thanks

Link:

<a class="signIn" href="#" onclick="doLogin(); return false;"/>
2
  • 3
    How about simply calling doLogin() directly? Commented Feb 16, 2011 at 11:39
  • Or pass this through to the click event Commented Feb 16, 2011 at 14:17

2 Answers 2

1

use click or bind functions in jquery that will make it simple

$('.signIn').click(function(){
     alert('link clicked');
});

if you want to get the link clicked programmatic you can use $('.signIn').click();

refer Click http://api.jquery.com/click/

and Bind http://api.jquery.com/bind/

Sign up to request clarification or add additional context in comments.

Comments

0

if you are aware of jQuery you can do

jQuery(".signIn").click();

if not then you can try document.getElementsByTagName('a') it will return you an array of href elements. It will be easy for you to find your HREF if you can find it in a loop and check if its having attribute class=signIn.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.