在 JavaScript 中,如果窗口大小大于 500 像素,我会告诉浏览器执行某些操作。我这样做:
if (windowsize > 500) {
// do this
}
这很好用,但我想应用相同的方法,但使用一系列数字。所以如果窗口大小在 500px 和 600px 之间,我想告诉我的浏览器做一些事情。我知道这行不通,但这是我的想象:
if (windowsize > 500-600) {
// do this
}
这在 JavaScript 中甚至可能吗?
原文由 Dyck 发布,翻译遵循 CC BY-SA 4.0 许可协议
Tests whether
windowsize
is greater than500
and lesser than600
meaning that neither values500
or600
itself will导致条件变为真。