2 回答
TA贡献1802条经验 获得超4个赞
如果您想实现这一点,我建议您option使用 for 循环或映射显示标签,并从要映射的数组中删除重复项。您可以通过使用 ES6 来实现这一点Set。
所以假设你有以下代码:
const array = ['Family', 'Family', 'Wildelife', 'Wildlife'];
const uniqueSet= new Set(array);
const uniqueArray = [...uniqueSet];
//the new array will be ['Family', 'Wildlife']
TA贡献1845条经验 获得超8个赞
在选择标签中添加一个属性 id="tour_category" 并尝试
$(document).ready( function(){
var a = new Array();
$("#tour_category").children("option").each(function(x){
test = false;
b = a[x] = $(this).val();
for (i=0;i<a.length-1;i++){
if (b ==a[i]) {
test =true;
}
}
if (test) {
$(this).remove();
}
})
});
- 2 回答
- 0 关注
- 127 浏览
添加回答
举报