tags:

views:

38

answers:

3

I am working with a dynamic navigation and need to be able to target one specific link to open in a new window.

I need some help with the jQuery to do this.

For example I would like to be able to target the navigation item of Education which has a link of http://www.foo.com/education and have it open in new window when I click on it.

Would appreciate some assistance.

Thanks.

+2  A: 

try:

$("a[href='http://www.foo.com/education']").attr('target', '_blank');
Josh
It should work but it doesn't. Please take a look: http://globalhealth-dev.oit.duke.edu/education/ and click on the Global Health Courses link. It should open in a new window.
fmz
you need to wrap it in a document ready function $(document).ready(function() { $("a[href='http://www.foo.com/education']").attr('target', '_blank'); });
Josh
A: 
window.open( $("a[href='example.com']").attr('href') );
dfens
+1  A: 

or just

<a href="http://www.food.com/education" class="education" target="_blank">Education</a>

don't know why you would need to do this with jQuery.

Chad
because this is not a static link. It is generated dynamically and I don't have the option to add that.
fmz