Element: getElementsByTagNameNS() ã¡ã½ãã
Baseline
åºãå©ç¨å¯è½
ãã®æ©è½ã¯åºãå®è£ ããã¦ãããå¤ãã®ãã¼ã¸ã§ã³ã®ç«¯æ«ããã©ã¦ã¶ã¼ã§åä½ãã¾ãã2015å¹´7æä»¥éããã¹ã¦ã®ãã©ã¦ã¶ã¼ã§å©ç¨å¯è½ã§ãã
Element.getElementsByTagNameNS() ã¡ã½ããã¯ãæå®ãããåå空éã«å±ãããæå®ãããã¿ã°åãæã¤è¦ç´ ã® HTMLCollection ãã©ã¤ãã§è¿ãã¾ãããã㯠Document.getElementsByTagNameNS ã«ä¼¼ã¦ãã¾ãããæ¤ç´¢å¯¾è±¡ãæå®ãããè¦ç´ ã®åå«ã«éå®ãããç¹ãç°ãªãã¾ãã
æ§æ
js
getElementsByTagNameNS(namespaceURI, localName)
弿°
namespaceURIã¯æ¤ç´¢ããè¦ç´ ã®åå空é URI ã§ãï¼Element.namespaceURIããã³Attr.namespaceURIãåç §ãã¦ãã ããï¼ãä¾ãã°ãXHTML è¦ç´ ãæ¤ç´¢ããå ´åã¯ãXHTML ã®åå空é URI ã§ããhttp://www.w3.org/1999/xhtmlã使ç¨ãã¦ãã ãããlocalNameã¯æ¤ç´¢ããè¦ç´ ã®ãã¼ã«ã«åãã¾ãã¯ãã¹ã¦ã®è¦ç´ ã«ä¸è´ããç¹æ®ãªå¤"*"ã§ãï¼Element.localNameããã³Attr.localNameãåç §ï¼ã
è¿å¤
çãã HTMLCollection ã§ãããªã¼å
ã§è¦ã¤ãã£ãè¦ç´ ãåºç¾é ã«ä¿æãã¾ãã
ä¾
js
// XHTML ææ¸ã® table ã®å¤ãã®ã»ã«ã®é
åããã§ãã¯ã
const table = document.getElementById("forecast-table");
const cells = table.getElementsByTagNameNS(
"http://www.w3.org/1999/xhtml",
"td",
);
for (const cell of cells) {
const axis = cell.getAttribute("axis");
if (axis === "year") {
// ãã¼ã¿ãåå¾
}
}
仿§æ¸
| 仿§æ¸ |
|---|
| DOM > # dom-element-getelementsbytagnamens > |