A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/fr/docs/Web/API/HTMLSelectElement/selectedIndex below:

HTMLSelectElement.selectedIndex - Les API Web

HTMLSelectElement.selectedIndex

Baseline Widely available

HTMLSelectElement.selectedIndex est un long qui représente l'index du premier élément sélectionné <option>. La valeur -1 indique qu'aucun élément est sélectionné.

Syntaxe
var index = selectElem.selectedIndex;
selectElem.selectedIndex = index;
Exemple HTML
<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>
</select>
JavaScript
var selectElem = document.getElementById("select");
var pElem = document.getElementById("p");

// Quand une nouvelle <option> est selectionnée
selectElem.addEventListener("change", function () {
  var index = selectElem.selectedIndex;
  // Rapporter cette donnée au <p>
  pElem.innerHTML = "selectedIndex: " + index;
});
Spécifications Compatibilité des navigateurs

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4