Baseline Widely available
HTMLFormControlsCollection.namedItem()
æ¹æ³è¿åéåä¸ç RadioNodeList
æ Element
ï¼å
¶ name
æ id
å¹é
æå®åç§°ï¼å¦ææ²¡æèç¹å¹é
ï¼åè¿å null
ã
请注æï¼æ¤çæ¬ç namedItem()
éèä» HTMLCollection
ç»§æ¿ç项ãä¸è¯¥æ¹æ³ç±»ä¼¼ï¼å¨ Javascript ä¸ï¼ä½¿ç¨æ°ç»æ¬å·è¯æ³åå符串ï¼ä¾å¦ collection["value"]
çä»·äº collection.namedItem("value")
ã
name
ä¸ä¸ªå符串ï¼ç¨äºå¹é
HTMLFormControlsCollection
å¯¹è±¡ä¸æ§ä»¶ç name
æ id
屿§ã
<form>
<label for="notes">å¤å¿å½ï¼</label>
<input id="notes" name="my-form-control" type="text" />
<label for="start">å¼å§æ¥æï¼</label>
<input id="start" name="my-form-control" type="date" />
</form>
<div id="output"></div>
JavaScript
const form = document.querySelector("form");
const items = form.elements.namedItem("my-form-control");
const output = document.querySelector("#output");
const itemIDs = Array.from(items)
.map((item) => `"${item.id}"`)
.join(", ");
output.textContent = `æç项ç®ï¼${itemIDs}`;
ç»æ è§è æµè§å¨å
¼å®¹æ§ åè§
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