I’m trying to come up with a javascript/jquery method that will allow me to remove all select list options containing a particular text pattern on page load.
So far I have:
$('select option:contains(\'foo\')')
Which returns me all the elements – how can I remove them? My initial thought was something along the lines of:
$('select option:contains(\'foo\')').each().remove();
But this throws an exception.
Am I approaching this incorrectly?
jQuery functions automatically work on all selected elements. No need to use
each()here.