Making a Single Link In Header Open In New Tab

I am trying to make one link in my header to open in a new tab. I don’t want all the links to open externally, just one. I am attaching a screenshot for reference.

Theme name: Ella

Store Link: https://testingstoresandthemes.myshopify.com/
storefront password: test

Thank you in Advance

Hello @technase
Apply the below lines in header.liquid


I pasted the code at the bottom of my header-navigation-plain.liquid (this is the header I am using) and it doesn’t work

Hi @technase ,

Try this , and if its still not working , kindly share the screenshot of the same .

var lastAnchorTag = document.querySelector("#HeaderNavigation > nav > ul > li:last-child > a")
lastAnchorTag.setAttribute("target", "_blank");

make Sure You wrap this code between tag .

1 Like

Hi @technase ,

The reason is that you are not putting the code I sent you in a script wrapper .

Perfect. Thank you.