I apologise for any stupid questions/coding, I'm very new to jquery!
I'm trying to create a menu for a one-page site that has rollovers and an active state. HTML:
<ul id="menu">
<li><a class="rollover" href="#"><img class="folio" src="images/folio3.png" /></a></li>
<li><a class="rollover" href="#"><img class="services" src="images/services3.png" /></a></li>
<li><a class="rollover" href="#"><img class="about" src="images/about3.png" /></a></li>
<li><a class="rollover" href="#"><img class="contact" src="images/contact3.png" /></a></li>
</ul>
jquery:
$(document).ready(function(){
$("a.rollover").fadeTo(1,0.5);
$("a.rollover").hover(
function() {$(this).fadeTo("fast",1);},
function() {$(this).fadeTo("fast",0.5);});
$("a.rollover").click(function(){
if($(".active").length) {
if($(this).hasClass("active")) {
$(this).removeClass("active");
$(this).fadeTo("fast",0.5);
} else {
$(".active").fadeTo("fast",0.5);
$(".active").removeClass("active");
$(this).addClass("active");
$(this).fadeTo("fast",1);
}
} else {
$(this).addClass("active");
$(this).fadeTo("fast",1);
}});
});
So there are two problems here:
Even though the active class is added and in Chrome's developer tools I can see that the opacity on an active class is "1", it doesn't seem to work in the browser, ie. the opacity still appears in the browser to be "0.5".
If $(this) is active, even after clicking $(this) thus removing the active class, the opacity remains at "1". If I click $(this) several times, eventually the opacity changes back to "0.5".
I'd really appreciate the help. I've been struggling with this for oh... 3 days now heh :-/
Many thanks in advance...