I have a dynamic navigation and need to open one link in a new window.
As such I am using jQuery to help, but the following code does not seem to work:
<script type="text/javascript">
$('a[href="http://globalhealth-dev.oit.duke.edu/education/global-health-courses"]').attr("target", "_blank");
</script>
To try it for yourself: http://globalhealth-dev.oit.duke.edu/education/ then click on the Global Health Courses link under Education.
I would appreciate some help getting this to work properly.
Thanks.
The selection part of your script is wrong, namely the href that should match the href in the element. Try with this:
$('a[href="/education/global-health-courses"]').attr("target", "_blank");Also note that it is not recommended to select that link using href as it is slower than just using a id in the element and then using $(“a#myid”).
Also be careful to call this only when the document is done loading: