I had a specific idea in mind - to create a simple menu bar where clicking on a particular link would display related content below. The chosen link should turn blue when selected. I managed to come up with the following code:
<a href="#" class="link">Link 1</a>
<a href="#" class="link active">Link 2</a>
<a href="#" class="link">Link 3</a>
a, a:visited { color:black }
a.link.active { color:blue; }
$(function() {
$('a.link').click(function() {
$('a.link').removeClass('active');
$(this).addClass('active');
});
});
Check it out on this Fiddle: https://jsfiddle.net/gHb9F/. It functions as intended, but I now want "Link 2" to be blue upon window load and change back to black once another link is clicked.