Source Code:
(back to article)
Submit
Result:
Report an issue
<div> <pre> <select id="colorSelector"> <option value="red">Red</option> <option value="blue">Blue</option> <option value="green">Green</option> </select> <script> document.getElementById('colorSelector').addEventListener('change', function(event) { alert('You selected ' + event.target.value); }); </script> </pre> </div>