JSFiddle - React, Tailwind, and code Playground

by ajthomascouk

HTML

<ul id="nav">
    <li><a href="ajthomascouk">This fiddle</a></li>
    <li><a href="foo">foo</a></li>
    <li><a href="bar">bar</a></li>
</ul>

JavaScript

pathname = $(location).attr('href');
$('#nav li > a').each(function(){
    thisHref = $(this).attr('href');
    if (pathname.toLowerCase().indexOf(thisHref) >= 0) 
        $(this).css({'color':'red'})
});