gpt4 book ai didi

javascript - 仅当屏幕大于时,我如何执行此功能

转载 作者:行者123 更新时间:2023-11-30 19:25:24 24 4
gpt4 key购买 nike

我只想在屏幕大于 1000px 时执行此功能。

window.addEventListener(
'scroll',
event => {
const nav = document.querySelector('.module')
if (250 <= window.scrollY) {
nav.classList.add('flyin')
nav.classList.remove('module')
}
else nav.classList.List.add('none')
},
false
)

最佳答案

if (window.innerWidth > 1000) {
window.addEventListener(
'scroll',
event => {
const nav = document.querySelector('.module')
if (250 <= window.scrollY) {
nav.classList.add('flyin')
nav.classList.remove('module')
}
else nav.classList.List.add('none')
},
false
)
}

关于javascript - 仅当屏幕大于时,我如何执行此功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56967207/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com