![](//s1.studylibfr.com/store/data-gzf/61fa5ccff7d793824b137ea81d33966d/1/010028001.htmlex.zip/bg2.jpg)
J.D.B. DIASOLUKA Nz. Luyalu
JavaScript Tome-
XXIV
L’élément < Select >
- 2 / 93 - dimanche, 26. mai 2019 (1:02 )
<option value="AMR" selected=true>Amaurose</option>
<option value="CCT">Cécité Corticale</option>
<option value="SCC">Scotome Central</option>
<option value="SCS" selected="selected">Scotome Scintillant</option>
<option value="SCP">Scotome Positif</option>
<option value="SCN">Scotome Négatif</option>
<option value="PST" selected>Post-Image</option>
<option value="MCT">Migraines Cataméniales</option>
</select>
<script type="text/javascript"> "use strict";
const s = document.querySelector(".cSel"),
sv = s.value,
si = s.selectedIndex,
so = s.selectedOptions;
for(let i in so) console.log(so[i])
// => <option value="AMR" selected="true">
// => <option value="SCS" selected="selected">
// => <option value="PST" selected="">
// => function item()
// => function namedItem()
// => 3
for(let i of so) console.log(i) // Mieux que le for...in
// => <option value="AMR" selected="true">
// => <option value="SCS" selected="selected">
// => <option value="PST" selected="">
for(let i=0 , l=so.length ; i<l ; i++) // Mieux que for...in
console.log(so[i])
// => <option value="AMR" selected="true">
// => <option value="SCS" selected="selected">
// => <option value="PST" selected="">
console.dir("s.value =",sv);
// s.value = AMR
console.dir("s.selectedIndex =",si);
// s.selectedIndex = 2
console.log("value de s.selectedIndex =",s[si]);
// value de s.selectedIndex =
// <option value="AMR" selected="true">
console.log("value de s.selectedIndex =",s[si].value);
// value de s.selectedIndex = AMR
console.log("text de s.selectedIndex =",s[si].text);
// text de s.selectedIndex = Amaurose
console.log("textContent de s.selectedIndex =",s[si].textContent);
// textContent de s.selectedIndex = Amaurose
console.log("innerHTML de s.selectedIndex =",s[si].innerHTML);