Click a Link from Javascript
by Sasikumar[ Edit ] 2014-07-28 16:21:13
To Trigger Click action of a link use the following method
Example Javascript Code:
<a id="mylink" href="http://hiox.org" onclick="somefunction()"></a>
<script type="text/javascript">
$mylink = $('#mylink');
$mylink[0].click(); // Triggers the click action and goes to hiox.org
$mylink.click(); // Calls the "somefuntion";
</script>
This helps in making a link navigate to its
href
. Note that we have to use
"[0]" for making a link navigate to its href.