谁能看到我在这里做错了什么?
我正在尝试拆分tag_filter
,然后对于每个tag_filter
值,我想检查选项值是否已存在于tag_select_dropdown_filter
. 如果它不存在,则将选项添加到tag_select_dropdown_filter
.
var tag_filter = new1,new2,new3;
var arraylist = tag_filter.Split(",");
jQuery.each(arraylist, function(index, item) {
if ($('select#tag_select_dropdown_filter option[value="'+item+'"]').length) {
// it exists
} else { var o = new Option("option text", item);
$(o).html("option text");
$("#tag_select_dropdown_filter").append(o);
}
});