ItSolutionStuff.com

JQuery Open Link in New Tab on Click Example

By Hardik Savani • July 20, 2023
jQuery

In this example, we will lean how to open link in new tab on button click event in jquery. we will see example of onclick open link in new tab jquery. we have two example of open url in new tab on button click jquery.

I created two way to open link in new tab in jquery. first one is a using window.open() and another is 'target="_blank"' on anchor tag. so i added both example bellow you have to just check that you can see how it will helps us.

Let's see both example and you can use anyone as you need.

Example 1:

 

<!DOCTYPE html>

<html>

<head>

<title>Jquery Open Link in New Tab on Click Example - ItSolutionStuff.com</title>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

</head>

<body>

<button class="btn">Click Me</button>

<script type="text/javascript">

$(".btn").click(function(){

window.open("https://www.itsolutionstuff.com");

})

</script>

</body>

</html>

Example 1:

 

<!DOCTYPE html>

<html>

<head>

<title>Jquery Open Link in New Tab on Click Example - ItSolutionStuff.com</title>

</head>

<body>

<a href="https://www.itsolutionstuff.com" rel="noopener noreferrer" target="_blank">Click Me</a>

</body>

</html>

I hope it can help you...

Tags: jQuery
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

JQuery Moment Add Seconds to Datetime Example

Read Now →

JQuery Moment Subtract Month Example

Read Now →

JQuery Open Link in New Window Example

Read Now →

JQuery Get Days Difference Between Two Dates Example

Read Now →

How to Set and Get Custom Attribute Value using JQuery?

Read Now →

Add Edit Delete Table Row Example using JQuery

Read Now →

JQuery Select Box with Search using Select2 JS Example

Read Now →

JQuery Validate File Size with Multiple File Upload Example

Read Now →

How to Check If Element is Exists or Not in jQuery?

Read Now →

Jquery Ajax Request Example Tutorial

Read Now →

How to Get Max Attribute Value in JQuery?

Read Now →

How to Remove Query String from URL using JQuery?

Read Now →

Automatically Scroll to Bottom of Div JQuery Example

Read Now →

Check and Uncheck All Checkbox using JQuery Example

Read Now →