I'm making a navigation for a website and would like the buttons to behave like this:
- Have the active button 40px higher than the others.
- Move buttons 10px higher on hover, unless it's the active button.
- When a button is clicked, remove active class from all buttons, move all of them to the original position, add active class to clicked button, move clicked button 40px higher.
This is my jQuery code:
$(document).ready(function(){
$('#navigation a').not(".active")
.mouseover(function(){
$(this).stop().animate(
{top:"-10px"},
{duration:200}
)
})
.mouseout(function(){
$(this).stop().animate(
{top:"0px"},
{duration:200}
)
})
.click(function(){
$('#navigation a.active').animate(
{top:"0px"},
{duration:200}
)
$('#navigation a').removeClass("active");
$(this).addClass("active");
$(this).stop().animate(
{top:"-40px"},
{duration:200}
)
})
});
Everything seems to work and the classes are being given and removed properly. The only problem is that the not() method keeps blocking the initial active button, and not the ones who have gotten the class later with addClass().