For instance, there’s a HTML select element identified by the ID #title, and after the user has selected one of the options, you want to get the text and value of the selected option.
<select id="title"> <option value="1">Mr</option> <option value="2">Mrs</option> <option value="3">Miss</option> </select>
Now that the user has selected the 2nd option: Mrs. To get the value (in this case, ‘2’):
Which is also the common function to return the value of all other form controls.
To get the text of the selected option (in this case, ‘Mrs’):