Alex Rivera | Logout

How to trigger click event on href element

Asked 2011-11-03T18:06:56.063
96

I'm trying to trigger click event on hyperlink with jQuery like the way below. Hyperlink does not have any id but it does have css class:

$(document).ready(function () {  
  $('.cssbuttongo').trigger('click'); 
}); 

The function above is not working. This is the hyperlink:

<a href="hyperlinkurl" class="cssbuttongo">hyperlink anchor</a>
Edit
Report

1 Answer

4

Triggering a click via JavaScript will not open a hyperlink. This is a security measure built into the browser.

See this question for some workarounds, though.

answered 2011-11-03T18:10:19.890

Your Answer