I'm using the jQuery .scroll() function, why can't I override its effects with another function?

Posted by Jason Rhodes on Stack Overflow See other posts from Stack Overflow or by Jason Rhodes
Published on 2010-04-16T05:46:35Z Indexed on 2010/04/16 5:53 UTC
Read the original article Hit count: 226

Filed under:
|
|

I'm using the jQuery .scroll() function to make a certain element fade to 0.2 opacity. Since there is no native "scrollstop" indicator, I decided to make the element fade back to 1.0 opacity on hover. However, it doesn't work.

Here's my code:

$(document).ready(function() {  
$(window).scroll(function() {
    $("#navlist").animate({ opacity: 0.2 }, 2000);
});

$("#navlist").hover(    
    function() {
        $(this).animate({ opacity: 1 }, 500);
    }, function() {
        $(this).animate({ opacity: 1 }, 500); // just to be safe?
    }
);
});

When I scroll, the #navlist element fades, but when you hover over it nothing happens. But if you refresh the page when you're half way down, the element automatically fades as soon as you refresh, before I've scrolled, and if you try to hover to fade it back in, nothing happens.

Any thoughts?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript