Having a select like this:
<select id="main">
<optgroup label="Coches">
<option value="Mustang">Mustang</option>
<option value="Ford">Ford</option>
</optgroup>
<optgroup label="Motos">
<option value="Scooter">Scooter</option>
<option value="Extra">Extra</option>
</optgroup>
</select>
I'm looking for a way to get the value of the option selected by the user through JavaScript, after many tests and information search I do not give the right one. As far as I know, you have to treat the optgroup as an object, and using an index you can get the selected option, right?
Greetings and thanks