how to avoid duplicate values in dropdownlist using jquery

Solutions on MaxInterview for how to avoid duplicate values in dropdownlist using jquery by the best coders in the world

showing results for - "how to avoid duplicate values in dropdownlist using jquery"
Idris
28 Nov 2018
1$(".select option").val(function(idx, val) {
2  $(this).siblings('[value="'+ val +'"]').remove();
3});
Abigail
08 Jan 2019
1<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
2
3<select class="select">
4  <option value="">All</option>
5  <option value="com">.com 1</option>
6  <option value="net">.net 1</option>
7  <option value="com">.com 2</option> <!-- will be removed since value is duplicate -->
8  <option value="net">.net 2</option> <!-- will be removed since value is duplicate -->
9</select>