Reputation: 69
I'm trying to include to conditions in a jQuery if statement.
This is my current code with the bold being what I'm trying to make work.
// Add scrolling Nav Bar
$(document).ready(function() {
var navpos = $('.nav-bar').offset();
console.log(navpos.top);
$(window).bind('scroll', function() {
if ($(window).scrollTop() > navpos.top && $(window).width() < 960)) {
$('.site-header .grid--full').hide(200);
$('.nav-bar-scroll').show(200);
}
else {
$('.site-header .grid--full').show(200);
$('.nav-bar-scroll').hide(200);
}
});
});
if ($(window).scrollTop() > navpos.top && $(window).width() < 960)) {
My ultimate goal is to hide the original header and display a new one when scrolling down the page.
Thank you kindly in advance!
Upvotes: 2
Views: 6608
Reputation: 2615
You have one )
too many.
if ($(window).scrollTop() > navpos.top && $(window).width() < 960))
Should be if ($(window).scrollTop() > navpos.top && $(window).width() < 960)
to be syntactically correct.
Opening up your Javascript Console in any browser will alert you to this error, which in my version of Firefox, reads: SyntaxError: expected expression, got ')'
- indicating you had an incorrect number of parentheses.
Upvotes: 5