jQuery menu active link
- by antosha
Hello,
I am trying to make a jquery menu that when I click on one of the links (without reloading the page), it changes its class to "active" and removes this class when I click on another link.
here is my code :
<script type="text/javascript">
$(document).ready(function() {
$(".buttons").children().("a").click(function() {
$(".buttons").children().toggleClass("selected").siblings().removeClass("selected");
});
});
</script>
<ul class="buttons">
<li><a class="button" href="#">Link1</a></li>
<li><a class="button" href="#">Link2</a></li>
<li><a class="button" href="#">Link3</a></li>
<li><a class="button" href="#">Link4</a></li>
</ul>
Can someone tell me why my code is not working and how to fix it?
Thanks :)