MDN self-hosted library · e01.org

HTMLSelectElement: item() method

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<form>
  <select id="myFormControl">
    <option id="o1">Opt 1</option>
    <option id="o2">Opt 2</option>
  </select>
</form>
js
// Returns the HTMLOptionElement representing #o2
elem1 = document.forms[0]["myFormControl"][1];