How to Open Button Link in New Tab Using jQuery

In this tutorial, learn how to open button link in new tab using jQuery. The short answer is: use jQuery window.open function with link first argument and _blank as the second argument.

You can open the internal link in the same window. However, somewhere you may require to open the internal link in the new tab. Again it’s the best practice for any blogger to open the external link in the new tab.

But, how you can create a button with a link and open the link in the new tab of the browser. To get the answer to this question, keep reading this post. You may also like to read how to create an anchor link button using Bootstrap.

How to Open Button Link in New Tab Using jQuery

To open button link in new tab, you have to use the onclick attribute with the button. Add the jQuery window.open() in the onclick attribute of the button. The onclick attribute works when someone clicks on the button.

Now, You have to add two arguments in the jQuery window.open() function.

The first argument of the function requires to add URL and the second takes _blank. See the example below to create your own anchor link button.

Test it Live

Output


The above example contains the button with the URL in the onclick attribute of HTML. Click the above button that takes you to the new tab with link opened.

You may also like to read

i Hope, you like this tutorial of how to open link in new tab using jQuery. If you have any query regarding the tutorial, please comment below.

References

Also tell me, which method you are using to open the link in new tab with jQuery.

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.