javascripthtmltabsanchor

Open every link in new tab


I know I can open a link in a new tab by adding target _blank attribute to the anchor tag.

But is there any way I can trigger every link in my website to open in new tab?


Solution

  • Are you looking for a CSS solution only? or any solution like the one below (JQuery)

    $('a').click(function() {
      $(this).attr('target', '_blank');
    });
    

    And also you can add the code below in your head tag-

    <base target="_blank">
    

    this will make all the a tags open in a new tab