有条件的,如果对于很多值,更好的方法 [英] conditional if for many values, better way

查看:56
本文介绍了有条件的,如果对于很多值,更好的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有更好的方法来处理检查多个值。当我有超过3个选择时,它开始变得非常忙碌。

Is there a better way to deal with checking multiple values. It starts to get really busy when I have more than 3 choices.

if (myval=='something' || myval=='other' || myval=='third') {

}

PHP有一个名为的函数in_array ()使用如下:

PHP has a function called in_array() that's used like this:

in_array($myval, array('something', 'other', 'third')) 

在js或jquery中有类似的东西吗?

Is there something like it in js or jquery?

推荐答案

Jquery。 inArray()

这篇关于有条件的,如果对于很多值,更好的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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