Skip to content

Instantly share code, notes, and snippets.

@sirlancelot
Created December 30, 2011 19:50
Show Gist options
  • Select an option

  • Save sirlancelot/1541209 to your computer and use it in GitHub Desktop.

Select an option

Save sirlancelot/1541209 to your computer and use it in GitHub Desktop.
Creates a jQuery selector that matches all external links
jQuery.expr[':'].external = function(obj) {
return !obj.href.match(/^mailto\:/) && (obj.hostname != location.hostname);
};
// Add class to all external links
$('a:external').addClass('external');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment