How do I display the selected option name in the div above it? If user has blue selected I want blue to show above.
<div id='text"> selection goes here</div>
<select id="dropdownselect">
<option> Red </option>
<option> White </option>
<option> Blue </option>
</select>
Use the following to get the text of the selected option:
Then, to add the value to the
divwith idtext, use:If you want to reflect the selected value every time the option has changed, you need to attach the
onchangeevent to theselect, which, combined with the above code results in the following:Here’s a working DEMO.