- This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › [SOLVED] Fixed nav and logo on scroll
New member here so please excuse my issue if its an easy one.
This works for fixed nav on scroll…
(function($) {
$(window).bind(‘scroll’, function () {
if ($(window).scrollTop() > 200) {
$(‘#g-navigation’).addClass(‘fixed’);
}
else {
$(‘#g-navigation’).removeClass(‘fixed’);
}
});
})
(jQuery);
with this css…
.fixed {
position: fixed !important;
top: 0;
left: 0;
right: 0;
}
However when trying to add this code to change my menulogo from display: none; to block; it doesnt work.
This code…
(function($) {
$(window).bind(‘scroll’, function () {
if ($(window).scrollTop() > 200) {
$(‘#g-navigation’).addClass(‘fixed’);
$(‘menulogo’).addClass(‘menulogoblock’);
}
else {
$(‘#g-navigation’).removeClass(‘fixed’);
$(‘menulogo’).removeClass(‘menulogoblock’);
}
});
})
(jQuery);
with this css…
.menulogo {
display: none;
}
.menulogoblock {
display: block !important;
}
Any ideas why i cant get the logo to turn “on” when i scroll?
Thanks =)
Can you make a demo of this?
I did notice a small syntax error, where it should be:
$('.menulogo').addClass('menulogoblock'); // note the dot to target the class
Winner winner chicken dinner!!!
You rock Atelierbram! It was the freak’n . missing. I didnt think it needed it cause the #g didnt have one? Why would one need it and the other not?
Thanks again Atelierbram, my code is working now =)