JSFiddle - React, Tailwind, and code Playground

by Emily Humphrey

HTML

<a href="mailto:[email protected]">Should not be red</a>
<a href="http://reddittest.com">Should be red</a>
<a href="http://fiddle.jshell.net/">Should not be red</a>

CSS

body{
    padding: 0;
    margin: 0;
    font-family: sans-serif;
}
a{
    display: block;
    padding: 2px;
    margin: 2px;
    text-decoration: none;
    color: blue;
}
a[target="_blank"]{
    color: red
}

JavaScript

$('a').each(function() {
		var link = new RegExp("/"+window.location.host+"/");
		if(!link.test(this.href)){
			if(this.href.substring(0, 7) != "mailto:"){
				$(this).attr("target", "_blank");
			}
		}
	});