How To Open New Tab In Jquery

Opening a new tab using JavaScript can be as simple as using the function. However, when working with jQuery, we might want to incorporate this functionality into our existing jQuery codebase. In this blog post, we’ll explore how to open a new tab in jQuery.

Using the Function

Before diving into jQuery, let’s quickly review how to open a new tab using plain JavaScript. The function is used to open a new browser window or a new tab, depending on the browser settings. The syntax is as follows:, windowName, [windowFeatures]);

The function takes three parameters:

  • url: The URL of the page to open in the new window.
  • windowName: A name for the new window. This can be used as a reference to manipulate the window later.
  • windowFeatures (optional): A string that specifies additional features for the new window (e.g., width, height, and scrollbars).

To open a new tab, we just need to call the function with the desired URL and an empty string as the windowName parameter. For example:'', '_blank');

Opening a New Tab in jQuery

Now that we know how to open a new tab using JavaScript, let’s see how we can do the same with jQuery. The process is quite simple – we just need to select the element that should trigger the new tab action and attach a click event handler to it. In the event handler, we can then call the function. Here’s an example:

$(document).ready(function() {
  $('#open-new-tab').click(function() {'', '_blank');

In this example, we use the jQuery $(document).ready() function to ensure that our code is executed once the DOM is fully loaded. We then select the element with the ID open-new-tab and attach a click event handler to it. Inside the event handler, we call the function as we did earlier.

To see this in action, add the following HTML to your page:

<button id="open-new-tab">Open New Tab</button>

Now, when you click the “Open New Tab” button, a new tab will open with the specified URL.


In this blog post, we’ve explored how to open a new tab in jQuery by attaching a click event handler to an element and calling the function. This technique can be easily integrated into your existing jQuery codebase and provides a simple way to open new tabs as needed.