1
我試圖一起使用2件jQuery - 他們單獨工作但不在一起。
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);
和
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');
}
});
我只能假設它的東西做$(window).scroll
...?
和實際的問題是...? – Frankie 2010-08-19 22:33:24
你的控制檯是否有錯誤?可能有一個錯誤,另一個沒有運行。 – 2010-08-19 22:34:29
不要說「它沒有工作」,告訴我們應該發生什麼,個人,工作部分是幹什麼的,以及實際發生的事情。使用Firefox,並轉到工具>錯誤控制檯檢查JavaScript錯誤。你也可以使用Firebug插件來調試你的jquery。 – RMorrisey 2010-08-19 22:43:56