Let's say we have a dropdown list:
<select id="select">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
</select>
Question: how do we get all the items in this list? The easiest way is to use the appropriate selector:
let options = document.querySelectorAll('#select option');
console.log(options);
The search for option
tags can be provided not in the entire document,
but specifically in our select:
let select = document.querySelector('#select');
let options = select.querySelectorAll('option');
console.log(options);