This page discusses - JavaScript getElementById select We can use document.getElementById() over the
6228
Your browser seems to have JavaScript disabled. Make sure JavaScript is enabled or try opening a new browser window. For 24-hour cancer information and support, contact the American Cancer Society at 1-800-227-2345
Then we can call appendChild on the select element to append it as a child of the select element. For instance, we can write the following HTML: to create an empty select element. Then we can add the option elements for the select element by writing:
Syntax. Return the selected property: optionObject .selected. Set the selected property: optionObject .selected = true|false. const log = console.log; const areaSelect = document.querySelector (` [id="area"]`); areaSelect.addEventListener (`change`, (e) => { // log (`e.target`, e.target); const select = e.target; const value = select.value; const desc = select.options [select.selectedIndex].text; log (`option desc`, desc); });