【发布时间】:2023-01-24 22:04:40
【问题描述】:
我使用以下代码构建一个数组:
var intestColonne = [];
$('.tbi').find('tr:first th').each(function(){
intestColonne.push(($(this).children('select').val()));
});
//intestColonne=intestColonne.pop(); //if this row is parsed the array becomes undefined
现在我想检查数组中是否有多个特定值的条目:
if(intestColonne.filter(x => x === "importo").length>1){
//check the index of each "importo" element
//store it into variables
//remove all the other "importo" leaving only the first (lowest index)
}
我停留在第一步,因为我还没有找到可以返回“importo”值的所有索引的特定函数。
indexOf 将返回第一个索引,lastIndexOf 将返回最后一个。使用 indexOf 我可以指定从哪里开始寻找,但这很难满足我的目标。
我可以使用其他类型的搜索吗?
【问题讨论】:
标签: javascript jquery arrays