I have this code here,
我这里有这个代码,
$(document).ready(function(){
$(window).load(function() {
window.addEventListener("hashchange", function() { scrollBy(0, -50);});
var shiftWindow = function() { scrollBy(0, -50);};
if (location.hash) shiftWindow();
window.addEventListner("hashchange", shiftWindow);
});
});
works great but I'm getting an error on my home page stating "error window.addEventListener isn't not a function. Can you tell me what I'm doing wrong. did I not close this loop right or something?
工作得很好,但我在我的主页上收到错误,说明“错误window.addEventListener不是一个函数。你能告诉我我做错了什么。我没有关闭这个循环或者什么?
1 个解决方案
#1
0
use jQuery!
$(window).on("hashchange", function() { scrollBy(0, -50);});
#1
0
use jQuery!
$(window).on("hashchange", function() { scrollBy(0, -50);});