Last active
August 29, 2015 14:03
-
-
Save aronduby/8ed8f8e61f986b34c0d1 to your computer and use it in GitHub Desktop.
jQuery External Link Selector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// external link selector | |
// $('a:external').addClass('external'); | |
$.expr[':'].external = function(obj){ | |
return (obj.href != undefined) | |
&& (obj.href != '') | |
&& !obj.href.match(/^mailto\:/) | |
&& !obj.href.match(/^tel\:/) | |
&& !obj.href.match(/^sms\:/) | |
&& (obj.hostname != location.hostname); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment