表达“大于x且小于y”? [英] Expression for "more than x and less than y"?

查看:154
本文介绍了表达“大于x且小于y”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试指定数字是否大于0但小于8.如何在JavaScript中执行此操作?

I'm trying to specify if a number is greater than 0 but less than 8. How do I do that in JavaScript?

这就是我的意思尝试:

if (score > 0 < 8) { alert(score); }

但是,上述结果会导致语法错误。

However, the above results in a syntax error.

推荐答案

以下是代码:

if (score > 0 && score < 8){
    alert(score);
}

P.S。这与jQuery无关。这很简单, JavaScript!

P.S. This has nothing to do with jQuery. It's simple, naked JavaScript!

这篇关于表达“大于x且小于y”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆