Remove Duplicates From Two Select Boxes

Remove Duplicates From Two Select Boxes

I have two selects. The first being the select to remove the options from, and the second being the source to find duplicates from.

How do I use jQuery to remove the the options from the first, if, and only if the option value is in the first and the second select?

Would like a function, something like:

removeDuplicates($("#select_1"), $("#select_2");

Thanks very much.

EX:

BEFORE DUPLICATES REMOVED:

[1st Select]
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>

[2nd Select]
<option value="1">1</option>
<option value="3">3</option>

AFTER DUPLICATES REMOVED (FINAL RESULT):

[1st Select]
<option value="2">2</option>

[2nd Select]
<option value="1">1</option>
<option value="3">3</option>
    • Topic Participants

    • info