Baseline Widely available
HTMLSelectElement.selectedIndex
㯠long
å¤ã§ããã鏿ããã¦ãã <option>
è¦ç´ ã®ãã¡ãmultiple
ã®å¤ã«å¿ãã¦æåã¾ãã¯æå¾ã®ãã®ãè¿ãã¾ãã-1
ã®å¤ã¯é¸æããã¦ããè¦ç´ ããªããã¨ã示ãã¾ãã
æ°å¤ã§ãã
ä¾ 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
const selectElem = document.getElementById("select");
const pElem = document.getElementById("p");
// When a new <option> is selected
selectElem.addEventListener("change", () => {
const index = selectElem.selectedIndex;
// Add that data to the <p>
pElem.textContent = `selectedIndex: ${index}`;
});
çµæ 仿§æ¸ ãã©ã¦ã¶ã¼ã®äºææ§
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