<select name="fruit">
<option value="id_1">Orange</option>
<option value="id_2">Apple</option>
<option value="id_3">Banana</option>
</select>
const select = document.querySelector('select');
select.addEventListener('input', () => {
alert(select.options[select.options.selectedIndex].textContent);
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.