jquery如何判断数组里是否包含abc
可以使用jQuery的inArray()方法来判断数组里是否包含指定的元素。
示例代码如下:
var arr = ["abc", "def", "ghi"];
if(jQuery.inArray("abc", arr) != -1){
console.log("数组中包含abc");
}else{
console.log("数组中不包含abc");
}
输出结果为:数组中包含abc
原文地址: https://www.cveoy.top/t/topic/dxib 著作权归作者所有。请勿转载和采集!