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>
I do not have factual evidence to prove this but I already ran into this issue. It seems that triggering a click() event on an
<a>tag doesn’t seem to behave the same way you would expect with say, a input button.The workaround I employed was to set the location.href property on the window which causes the browser to load the request resource like so:
Edit:
I would make a js fiddle but the nature of the question intermixed with how jsfiddle uses an iframe to render code makes that a no go.