开发者

Click link without id using javascript

开发者 https://www.devze.com 2023-02-11 23:26 出处:网络
Today I\'d try to click link using javascript. I don\'t know id, only class. Have u got any ideas ? Thanks

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

Thanks

开发者_JS百科Link:

<a class="signIn" href="#" onclick="doLogin(); return false;"/>


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/


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消