Skip to content

Instantly share code, notes, and snippets.

@craigmdennis craigmdennis/click.js
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.