-1

I want to open a link in a new tab. To do this I am writing a code like this:-

$(document).ready(function(e) {
    $('ul.sf-menu.sf-navbar li li a:contains("/events/aqr-investment-symposium-for-merrill-lynch/custom-20-a60da1b5daf74421bb19860b0769e3ba.aspx")').attr("target","_blank");
});

It's not working for me.

I cannot touch the HTML code. I can just make it done with jquery or javaScript.

Rohit Mehra
  • 229
  • 3
  • 15
  • possible duplicate of [JavaScript open in a new window, not tab](http://stackoverflow.com/questions/726761/javascript-open-in-a-new-window-not-tab) – Tushar Jun 30 '15 at 09:57

1 Answers1

0

You need to use the href of anchor element for opening in new window:

window.open($('ul.sf-menu.sf-navbar li li a:contains("/events/aqr-investment-symposium-for-merrill-lynch/custom-20-a60da1b5daf74421bb19860b0769e3ba.aspx")').attr('href'));
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125