How to Remove duplicate dropdown option elements with same value

后端 未结 8 1084
孤城傲影
孤城傲影 2020-12-03 18:48

How can I remove duplicate values -> drop down option elements?
I have the following HTML:


8条回答
  •  半阙折子戏
    2020-12-03 19:11

    You can use the following code to remove options with duplicate values.

        $(document).ready( function(){
            var a = new Array();
            $("#selectID").children("option").each(function(x){
                test = false;
                b = a[x] = $(this).val();
                for (i=0;i

提交回复
热议问题