使用jQuery过滤具有不同值的下拉列表 [英] Filter dropdown with distinct value using jquery
本文介绍了使用jQuery过滤具有不同值的下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
谁能告诉我如何使用唯一值过滤下拉列表,现在在我的下拉列表中添加这种值:
san
san
san
vert
vert
vert
pref
pref
pref
我想要这个:
san
vert
pref
我从解析XML填充了我的下拉列表.
Hello everyone,
Can anyone tell me how can I filter dropdown with unique values, rite now i''ve this kind of values in my dropdown:
san
san
san
vert
vert
vert
pref
pref
pref
I want this :
san
vert
pref
I populated my dropdown from parsing XML.
推荐答案
您可以使用jQuery的.unique.
例如
You can use jQuery''s .unique .
e.g.
.unique([" ," ," c", d" ," ]);
.unique(["a", "b", "c", "d", "a"]);
将返回a,b,c,d.
更多信息: http://api.jquery.com/jQuery.unique/
will return a,b,c,d.
More info: http://api.jquery.com/jQuery.unique/
你好,
您可以尝试以下-
Hi,
You can try below-
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js" type="text/javascript"></script>
<script type="text/javascript">
var ddlValues = ["san", "san", "san", "vert", "vert", "vert", "pref", "pref", "pref"];
var arrDistinct = new Array();
这篇关于使用jQuery过滤具有不同值的下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文