The HTMLSelectElement.selectedIndex is a long that reflects the index of the first selected <option> element. The value -1 indicates that no element is selected.


var index = selectElem.selectedIndex;
selectElem.selectedIndex = index;



<p id="p">selectedIndex: 0</p>

<select id="select">
  <option selected>Option A</option>
  <option>Option B</option>
  <option>Option C</option>
  <option>Option D</option>
  <option>Option E</option>


var selectElem = document.getElementById('select')
var pElem = document.getElementById('p')

// When a new <option> is selected
selectElem.addEventListener('change', function() {
  var index = selectElem.selectedIndex;
  // Add that data to the <p>
  pElem.innerHTML = 'selectedIndex: ' + index;


Specification Status Comment
HTML Living Standard
The definition of 'HTMLSelectElement' in that specification.
Living Standard No change since the latest snapshot, HTML5.
The definition of 'HTMLSelectElement' in that specification.
Recommendation Initial definition, snapshot of HTML Living Standard.

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome ? Edge ? Firefox ? IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?


Compatibility unknown  
Compatibility unknown

Document Tags and Contributors

Contributors to this page: connorshea, Druzion, teoli, Sebastianz, stephaniehobson
Last updated by: connorshea,