<script> </script>
<select id="select"> <option value="#ff0000">Red</option> <option value="#09bd45">Green</option> <option value="#3f00ff">Blue</option> </select>
<script> const selectE = document.querySelector('#select'); selectE.addEventListener('change', (event) => { const selectedIndex = event.target.selectedIndex; const options = event.target.options; const selectedOption = options[selectedIndex]; const selectedText = selectedOption.text; const selectedValue = selectedOption.value; alert(`You selected: ${selectedText} (${selectedValue})`); }); </script>