I learned recently that clicking on a select element’s label will cause the select element to reset. For example, if I have the following:
<label for “color”>Select a color</label>
<select name=”color” id=”color”>
<option selected>Select one</select>
<option>red</option>
<option>blue</option>
<select>
A user chooses, “red”. If the user then clicks on the “Select a color” text, the dropdown will reset to “Select one”.
So, here is my question. Is there, 1. a way to prevent that behavior or 2. a way to attach a function that will execute any time a user clicks a form label?
Thanks in advance
Edit – One other possibility – Could I write a function that would disable the onclick event in all select element labels?