Open a new tab on click using jQuery

jquery new tab

Today, I will teach how to redirect a page in a new tab using jquery.

Generally, People are using target=”_blank” method which provided by HTML but you can try another way using Jquery.

So here, we can start our tutorials.


Create an HTML file.

<!DOCTYPE html>
<html>
<head>
	<h1>Open a new tab on click using jQuery.</h1>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
	<button class="new_tab" id="new_tab">Submit</button>
	<script type="text/javascript">
	    $(".new_tab").click(function(){
	        window.open("https://www.facebook.com");
	    });
	</script>
</body>
</html>

So open your browser and put the below code:

http://localhost/new_tab.html

About Dhaval Shah

My name is Dhaval Shah. I'm a Laravel developer. I live in India and I love to write tutorials and tips that can help other developers. I am a big fan of PHP, Java-script, JQuery, Laravel, WordPress, and Bootstrap.
Follow me on Github / Linkedin

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!