Click a Link from Javascript

by Sasikumar 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.
1558
like
0
dislike
0
mail
flag

You must LOGIN to add comments