Apply CSS style to anchor problem
- by Jake
Using jquery I have a clicking tab mechanism that are nothing but anchor tags that return false but call javascript functions to run some events on the page. The problem is I am using jquery to apply an opacity style to the active anchor. and the other sibling anchor get a lesser opacity view. My code looks like this
$("#menutab li a").click(function(){
$(this).animate({opacity:'1'},1000);
$(this).siblings().animate({opacity:'.25'},1000);
}
I would think this code would act only on the clicked element and apply that css style to that element and the other style to the other anchor tags except the clicked one. It kind of does that, but also what it does is leave the earlier clicked element to opacity =1, so if I click an element it sets it opacity to 1 and then if I click another one it sets it opacity to 1 while leave the earlier clicked one to 1 also instead of setting it to .25 like the others.
Edit:
I changed the above code to:
$("#menutab ul li").click(function(){
$(this).children().animate({opacity:'1'},1000);
$(this).siblings().children().animate({opacity:'.25'},1000);
});
and now I get the desired effect, except that when the first anchor in the list is clicked doesn't follow the event rules, When the first one is clicked its as if, the click event is not triggered, because no opacity style changes. which I don't understand.