Skip to content

Instantly share code, notes, and snippets.

@craigmdennis
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigmdennis/fe6944f860559ff57357 to your computer and use it in GitHub Desktop.
Save craigmdennis/fe6944f860559ff57357 to your computer and use it in GitHub Desktop.
Open all external links in a new window with one line of jQuery
$('.content').on('click', 'a[href*="//"]:not([href*="mysite.com"])', function(){
$(this).attr('target','_blank');
});
$(document).ready( fucntion(){
$('.content a[href*="//"]:not([href*="mysite.com"]').attr('target','_blank');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment