Javascript 班级获胜';t在滚动上切换

Javascript 班级获胜';t在滚动上切换,javascript,html,Javascript,Html,有人能帮我吗?每当我尝试滚动时,类none不会切换 window.addEventListener('scroll',function(){ var header=document.getElementsById(“此处”); header.classList.toggle(“无”,window.scrollY>0); }); 。无{ 显示:无; } 您没有关闭img的id并编写elementsbyid而不是elementbyid window.addEventListener('scrol

有人能帮我吗?每当我尝试滚动时,类none不会切换

window.addEventListener('scroll',function(){
var header=document.getElementsById(“此处”);
header.classList.toggle(“无”,window.scrollY>0);
});
。无{
显示:无;
}

您没有关闭img的id并编写
elementsbyid
而不是
elementbyid

window.addEventListener('scroll',function(){
var header=document.getElementById(“此处”);
header.classList.toggle(“无”,window.scrollY>0);
});
。无{
显示:无;
}

img标记不应该需要一个类属性来切换吗?
id=“here>应该是:id=“here”>
没有像
getElementsById
id`这样的东西是唯一的,它应该是:
getElementById
,投票关闭是因为被输入错误迷住了。投票关闭是因为它只有两个输入错误。