Suppose I have a Select element:
<select>
<option value="Name 1">Simon</option>
<option value="Name 2">Frank</option>
<option value="Name 3">Bob</option>
<option value="Name 4">Alex</option>
</select>
And I have an array of strings, suppose:
["Simon", "Alex"]
How do I remove from the DOM (using jQuery) every option element that does not have a inner html value contained in the above list? For example, given the above list of inner html values (["Simon", "Alex"]), I would like to remove only the <option value="Name 2">Frank</option> and <option value="Name 3">Bob</option> elements, so that the final select element would look like:
<select>
<option value="Name 1">Simon</option>
<option value="Name 4">Alex</option>
</select>