I'm trying to create a stacked navigation list that highlights which item you have selected. It looks like this.
<div class="page-list">
<ul class="nav nav-pills nav-stacked">
<li><a href="Page1.html" > Page1 </a></li>
<li><a href="Page2.html" > Page2 </a></li>
<li><a href="Page3.html" > Page3 </a></li>
<li><a href="Page4.html" > Page4 </a></li>
<li><a href="Page5.html" > Page5 </a></li>
<li><a href="Unavailable.html" > Page6 </a></li>
<li><a href="Unavailable.html" > Page7 </a></li>
</ul>
</div>
The issue I am having is that the last two pages share the same link and I cant seem to get just the selected page to be highlighted in the list.
I was using this for my JavaScript.
<script>
$(function(){
$('a').each(function() {
if ($(this).prop('href') == window.location.href) {
$(this).addClass('current');
}
});
});
</script>
But this causes all links to the same page to highlight.
I tried solving it with this, but now no links highlight when clicked.
<script>
$(".page-list a").click(function() {
$(this).parent().previoussibling().find('a').removeClass('current');
$(this).addClass("current");
});
</script>