jquery trigger click on link

Today, We want to share with you jquery trigger click on link.In this post we will show you how to call click event of anchor tag in jquery?, hear for jquery execute click on link we will give you demo and example for implement.In this post, we will learn about JQuery Triggers Function Viewport with an example.

How to Trigger a Click on a Link Using jQuery?

Example 1: index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Triggers Click on a Link - www.pakainfo.com</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
function doSomething(){
    alert("Click event is triggered on the link.");
}
$(document).ready(function(){
    $("button").click(function(){
        $("a")[0].click();
    });
});
</script>
</head> 
<body>
    <p><a href="#skyImage" onclick="doSomething()">Bookmark link to an image</a></p>
    <button type="button">Triggers Click</button>
    <div style="margin-top: 800px;">
        <img src="/examples/images/sky.jpg" id="skyImage" alt="Cloudy Sky">
    </div>
</body>
</html>

How to handle a link click event using jQuery?

Example 2: index.html

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
 $(document).ready(function(){
    $("a").click(function(){
        alert("You've clicked the link.");
    });
 });
</script>
</head>
<body>

<p>Click below link.</p>
<a href="#">Click</a>

</body>
</html>

I hope you get an idea about jquery call function on click.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.