[英]Jquery waypoints with smooth scroll
我在這里使用JQuery航點有點麻煩。 我在一頁網站上將其用於自動滾動導航:
當我使用滾輪時效果很好。 每當某個元素到達屏幕頂部時,我都需要它來更改導航項的顏色。 問題是當您按注冊->關於->注冊時,第三次沒有改變顏色。
的script.js:
$('a[href^="#"]').bind('click.smoothscroll',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top-40
}, 900, 'swing', function () {
window.location.hash = target;
});
});
var currentMenuObject = '';
$('#wrapper').waypoint(function() {
$(currentMenuObject).css('color', '#f2e0bd');
currentMenuObject = '#top';
$(currentMenuObject).css('color', 'black');
}, { offset: '55'});
$('#introarticle').waypoint(function() {
$(currentMenuObject).css('color', '#f2e0bd');
currentMenuObject = '#top';
$(currentMenuObject).css('color', 'black');
}, { offset: '55'});
$('#signsection').waypoint(function() {
$(currentMenuObject).css('color', '#f2e0bd');
currentMenuObject = '#signup';
$(currentMenuObject).css('color', 'black');
}, { offset: '55'});
$('#storyarticle').waypoint(function() {
$(currentMenuObject).css('color', '#f2e0bd');
currentMenuObject = '#about';
$(currentMenuObject).css('color', 'black');
}, { offset: '55'});
您在將jquery添加到頁面之前正在調用此位:
$(document).ready(function(){
//jQuery code goes here and will be executed as soon as the page has finished loading
});
拋出$ is not a function
錯誤,並停止執行代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.