$().ready(function(){
let location = window.location.pathname.split('/')[1];
$('.ui-link').css('color', 'rgb(0, 0, 238)'); // reseting colors of all links
switch (location) {
case "test":
$("#nav_"+location).css('color', '#7e000b')
break;
case "other":
$("#nav_"+location).css('color', '#7e000b')
break;
default:
}
// onclick handler in case you arent doing an actual redirect (onepager)
$('.ui-link').click(function(){
location = $(this).id.split('_')[1];
$('.ui-link').css('color', 'rgb(0, 0, 238)'); // reseting colors of all links
$(this).css('color', '#7e000b'); // updating this link color
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<nav>
<a href="/test/" id="nav_test" class="ui-link">TEST</a>
<a href="/other/" id="nav_other" class="ui-link">OTHER</a>
</nav>