其他分享
首页 > 其他分享> > js去掉下拉框重复值

js去掉下拉框重复值

作者:互联网

<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(function(){
$("#batchId").each(function(i,n){
var options = "";
$(n).find("option").each(function(j,m){
if(options.indexOf($(m)[0].outerHTML) == -1)
{
options += $(m)[0].outerHTML;
}
});
$(n).html(options);
});
});
</script>

</head>
<body>
<html>
<body>


<select id="batchId">
<option>01</option>
<option>01</option>
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
</select>

</body>
</html>


</body>
</html>

标签:function,010101020304,下拉框,outerHTML,each,去掉,js,options
来源: https://www.cnblogs.com/20201201-jy/p/14072485.html