Reputation: 280
I'm trying to use jQuery to hide a div when the page loads, but when you scroll down to a certain point it will fade in. Right now the below script will do almost that, the problem I'm having is that the div is visible at first on page load, I want to hide it... I can't seem to figure out how.
$(window).bind("scroll", function() {
if ($(this).scrollTop() > 180) {
$("#magrig").fadeIn('slow');
}
else {
$("#magrig").stop().fadeOut('fast');
}
});
I've tried adding .hide() into the script, but I can't figure out how to reformat it.
I got it origonally from here: Fade in div after scrolling
Any help is greatly appreciated!
Upvotes: 0
Views: 1806
Reputation: 35950
You can hide the div
on page load, like this:
$(document).ready(function() {
("#magrig").hide();
});
Or you can do it directly in the CSS:
#magrig {
/* other CSS entries */
display:none;
}
Upvotes: 1
Reputation: 318182
How about just using plain old CSS, that will hide it on pageload :
#magrig {display:none}
Upvotes: 2