The thing I want to do is when a user clicks on a link, the background should change to Indicate which Link the user has clicked on. I'm trying to do this with jQuery:
$('.menuLink').click(function() {
var img = $(this).find('img');
var id = $(this).attr('id');
$("#" + id).addClass('activeLink');
console.log(id);
});
.menuLinks li {
color: #ffffff;
float: left;
margin-left: 2px;
width: 115px;
height: 60px;
background-color: #004f80;
text-align: center;
font-size: 13px;
font-weight: normal;
font-style: normal;
font-stretch: normal;
}
.menuLinks li:hover {
background-color: #006eb3;
cursor: pointer;
}
.menuLinks li a {
color: #fff;
}
.activeLink {
color: #004f80;
background-color: #fff;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="menuLinks">
<li class="menuLink" id="tillstandshavare">Link1</li>
<li class="menuLink" id="stationer">Lnk2</li>
<li class="menuLink" id="formular">Link3</li>
<li class="menuLink" id="fragor">Link4</li>
<li class="menuLink" id="installningar">Link5</li>
</ul>
As you can see, I'm attaching the activeLink class. But the background are never changed. I think this is because of menuLinks is not overrided.