0
我使用bootstrap編寫了一個菜單,使用JQuery滾動到我的頁面的不同部分,但在滾動主屏幕之前一秒鐘閃爍。我不知道爲什麼會發生,或者如何阻止它。JQuery滾動動畫瞬間閃爍主屏幕
$("#butHome").click(function() {
$(".nav li").removeClass("active");
$(this).addClass("active");
$('html, body').animate({
scrollTop: $("#home").offset().top
}, 300);
});
$("#but1").click(function() {
$(".nav li").removeClass("active");
$(this).addClass("active");
$('html, body').animate({
scrollTop: $("#section1").offset().top
}, 300);
});
$("#but2").click(function() {
$(".nav li").removeClass("active");
$(this).addClass("active");
$('html, body').animate({
scrollTop: $("#section2").offset().top
}, 300);
});
$("#but3").click(function() {
$(".nav li").removeClass("active");
$(this).addClass("active");
$('html, body').animate({
scrollTop: $("#section3").offset().top
}, 300);
});
$("#but4").click(function() {
$(".nav li").removeClass("active");
$(this).addClass("active");
$('html, body').animate({
scrollTop: $("#section4").offset().top
}, 300);
});
看來你的scrollTo代碼被重複多次,最好是創建一個函數有兩個參數或者是一個來處理。 – YEAMA
嘿謝謝我結束了一段時間的工作,但我很感激你花時間來幫助 – Olu87
沒問題...總是在那裏:D – YEAMA