I'm trying to use 2 pieces of jquery together – they work individually but not together.
checkShow();
function checkShow() {
var top = 0;
top = $(window).scrollTop();
if(top >= 600 && top < 1800) {
$('#lift:hidden').fadeIn({duration:500});
} else {
$('#lift').fadeOut({duration:1000});
}
if(top < 1800){
$("a[href='#uk']").parent().addClass("current");
$("a[href='#uk']").parent().siblings().removeClass("current");
}
if((top >= 1800) && (top < 3000)){
$("a[href='#mcr']").parent().addClass("current");
$("a[href='#mcr']").parent().siblings().removeClass("current");
}
if((top >= 3000) && (top < 4000)){
$("a[href='#lpool']").parent().addClass("current");
$("a[href='#lpool']").parent().siblings().removeClass("current");
}
if((top >= 4000) && (top < 5000)){
$("a[href='#bham']").parent().addClass("current");
$("a[href='#bham']").parent().siblings().removeClass("current");
}
if((top >= 5000) && (top < 6000)){
$("a[href='#offers']").parent().addClass("current");
$("a[href='#offers']").parent().siblings().removeClass("current");
}
if((top >= 6000) && (top < 7000)){
$("a[href='#groups']").parent().addClass("current");
$("a[href='#groups']").parent().siblings().removeClass("current");
}
if((top >= 7000)){
$("a[href='#groups']").parent().addClass("current");
$("a[href='#groups']").parent().siblings().removeClass("current");
}
}
$(window).scroll(checkShow);
and
var sbtop = $('#sidebar').offset().sbtop - parseFloat($('#sidebar').css('marginTop').replace(/auto/, 0));
$(window).scroll(function (event) {
// what the y position of the scroll is
var y = $(this).scrollTop();
// whether that's below the form
if (y >= sbtop) {
// if so, ad the fixed class
$('#sidebar').addClass('fixed');
} else {
// otherwise remove it
$('#sidebar').removeClass('fixed');
}
});
I can only assume it's something to do with $(window).scroll
...?