JSFiddle - React, Tailwind, and code Playground

by End_i

HTML

<h3>Les liens externes sont en noir :</h3>

<a href="mailto:[email protected]">Lien courriel</a><br />
<a href="/test1.html">Lien local</a><br />
<a href="http://www.google.ca/">Lien externe</a><br />

CSS

a {
    color:blue;
}
a.ext {
    color:black
}

JavaScript

/***
 * Création d'un sélecteur JQuery de liens externes
 * Utilisation :   $('a:external').addClass('ext').attr("target", "_blank");
***/
$(function(){
    // Creating custom  selector
    $.expr[':'].external = function(obj){
        return !obj.href.match(/^mailto\:/)
                && (obj.hostname != location.hostname);
    };
});




// Utilisation
// OnLoad
$(document).ready(function() {
    $('a:external').addClass('ext').attr("target", "_blank");
});