How can I remove duplicate values -> drop down option elements?
I have the following HTML:
Using .siblings() (to target sibling option elements), and Attribute Equals Selector [attr=""]
$(".select option").val(function(idx, val) {
$(this).siblings('[value="'+ val +'"]').remove();
});
(works also for multiple .select on the same page)
I added a class .select to the element to be more selector-specific
How it works:
while options are accessed one by one (by .val()) - lookup for .sibling() options that have the same "[value='"+ this.value +"']" and .remove() them.