반응형

[jQuery] Deleting duplicated values -> drop-down option list

 

select > option 에서 중복값 삭제하기. 

 

<select name="det_pas_object_gatve" class="det_pas_object_select_css">
<option selected="selected" value="">--- Choose street ---</option>
    <option value="Barrow">Barrow</option>
    <option value="Hornets">Hornets</option>
    <option value="Barrow">Barrow</option>
    <option value="Stanley">Stanley</option>
    <option value="Simon">Simon</option>
    <option value="Barrow">Barrow</option>
</select>
       var foundedinputs = [];
       $("select[name=det_pas_object_gatve] option").each(function() {
         if($.inArray(this.value, foundedinputs) != -1) $(this).remove();
         foundedinputs.push(this.value);
       });
반응형

+ Recent posts