Given an HTML form element, for example:
<select id='mydropdown'> <option value='foo'>Spam</option> <option value='bar'>Eggs</option> </select>
I know that I can choose the first option with
document.getElementById("mydropdown").value='foo'
However, let's say I have a variable with the value "Spam"; Can I select a dropdown item by its text, and not by its value?
source share