JSFiddle - React, Tailwind, and code Playground
by josekerekes
HTML
<a href="http://www.google.ro">hello</a>
<a href="http://www.yahoo.ro">hi</a>
<a href="#red">hi</a>
JavaScript
Array.from(document.querySelectorAll( 'a' )).forEach( a => {
if(location.hostname !== a.hostname || !a.hostname.length) {
a.classList.add('external');
}
});