在JavaScript中,如果窗口大小超过500px,我告诉浏览器执行某些操作。我是这样做的:
In JavaScript, I'm telling the browser to do something if the window size is greater than 500px. I do it like so:
if (windowsize > 500) { // do this }这很好用,但我想应用同样的方法,但是有一系列的数字。所以如果窗口大小介于500和600px之间,我想告诉我的浏览器。我知道这不会起作用,但这就是我想象的方式。
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 500 and 600px. I know this wouldn't work, but here is how I Imagined it.
if (windowsize > 500-600) { // do this }这在JavaScript中是否可行?
Is this even possible within JavaScript?
推荐答案测试 windowsize 是否大于 500 且小于 600 意味着值 500 或 600 本身将导致条件成立。
Tests whether windowsize is greater than 500 and lesser than 600 meaning that neither values 500 or 600 itself will result in the condition becoming true.
if (500 < windowsize && windowsize < 600) { // ... }更多推荐
如何检查数字是否介于两个值之间?
发布评论