I'm not very good with javascript so I would like to know how I get the name of an option when doing a change
:
Example:
<select id="ciudad">
<option value="1">Monterrey</option>
<option value="2">Tijuana</option>
<option value="3">Mexico D.F</option>
</select>
I know that if I do the following $(this).val();
and print it to the console, I will get the value of option
when doing the change
but, how do I show the name?
You can do it in the following way:
Example:
Dear colleague, I leave you an option in pure javascript, without the need to import any type of library. It's an option I always like to consider.
Cheers!.
PS: Improved code, thanks to the collaboration of Gustavo García.