I've created a navigation in a weird way due to how Cargocollective runs. As you can see there's a navigation on the side that scrolls to an anchor once clicked, each dot represents an anchor. What I'm trying to do is have it so when I click on one of the dots it remains a colour until I click another. Exactly like a a:active
would behave
a:active{color:green;}
is not working.
This is what I've done:
As you can see a link turns green when you click on it but it doesnt remain green like you'd expect from an active link.
HTML
<div id="navigation">
<a href="#i">•</a><br>
<a href="#ii">•</a><br>
<a href="#iii">•</a><br>
<a href="#iv">•</a><br>
<a href="#v">•</a><br>
<a href="#vi">•</a><br>
<a href="#vii">•</a><br>
<a href="#viii">•</a><br>
<a href="#ix">•</a><br>
<a href="#x">•</a><br>
<a href="#xi">•</a><br>
<a href="#xii">•</a><br>
<a href="#xiii">•</a><br>
</div>
CSS
#navigation {
position: fixed;
top: 50%;
margin-top: -140px;
right: 10px;
z-index: 1000;
text-align: center;
width: 180px;
font-size: 20px;
z-index: 9999;
}
#navigation a:link {
color: #aaa;
text-decoration: none;
}
#navigation a:hover {
color: #000;
}
#navigation a:active {
color: green;
}
JQUERY
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^//,'') == this.pathname.replace(/^//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});