Hey there! I'm currently working on adding a new feature to my website. I want the menu items to highlight in succession when clicked. For example, if I click on people
, I want it to highlight and then move on to highlight the next item in the menu, which would be tourist. I've been using CSS for hover effects, but I've heard that a:active
doesn't work with CSS. Can anyone provide some guidance on this?
Here's what I have done so far:
HTML
<section id="nav">
<li><a class="nav" href="People.html">People</a></li>
<li><a class="nav" href="Tourist.html">Tourist</a></li>
<li><a class="nav" href="Joints.html">Joints</a></li>
<li><a class="nav" href="Project.html">Project</a></li>
<li><a class="nav" href="Products.html">Products</a></li>
<li><a class="nav" href="cafes.html">cafes</a></li>
</section>
jQuery
<script>
$(function() {
$('#nav').on('click','.nav', function ( e ) {
e.preventDefault();
$(this).parents('#nav').find('.active').removeClass('active').end().end().addClass('active');
$(activeTab).show();
});
});
</script>
CSS
#nav{
width:100%;
text-align:center;
min-width:1300px;
height:80px;
position:absolute;
top:0;
left:0;
background:#fff;
list-style:none;
border-bottom: 1px solid #000;
}
#nav li{
display:inline;
}
#nav .nav{
display:inline-block;
background-color:#000;
color:#FFF;
font-family: 'Oswald', sans-serif;
letter-spacing:1px;
font-size:16pt;
line-height:18pt;
font-weight:400;
text-decoration:none;
margin-right: 3px;
margin-left: 3px;
margin-top:35px;
padding:0px 3px 2px 3px;
}
#nav .nav:hover{
background:#FFFF00;
color:#000;
}
.active{
background:#FFFF00;
color:#000;
}
If you have any tips or suggestions, please share! I'm currently stuck on this issue and any help would be greatly appreciated.