問題:
In JavaScript, I'm telling the browser to do something if the window size is greater than 500px.在 JavaScript 中,如果窗口大小大於 500 像素,我會告訴瀏覽器執行某些操作。 I do it like so:我這樣做:
if (windowsize > 500) {
// do this
}
This works great, but I would like to apply this same method, but with a range of numbers.這很好用,但我想應用相同的方法,但要使用一系列數字。 So I would like to tell my browser to do stuff if the window size is between 500px and 600px.所以如果窗口大小在 500px 和 600px 之間,我想告訴我的瀏覽器做一些事情。 I know this wouldn't work, but here is how I imagined it:我知道這行不通,但這是我的想象:
if (windowsize > 500-600) {
// do this
}
Is this even possible, within JavaScript?在 JavaScript 中,這甚至可能嗎?
解決方案:
參考一: https://en.stackoom.com/question/zky9參考二: https://stackoom.com/question/zky9