Element: children ããããã£
Baseline
åºãå©ç¨å¯è½
ãã®æ©è½ã¯åºãå®è£ ããã¦ãããå¤ãã®ãã¼ã¸ã§ã³ã®ç«¯æ«ããã©ã¦ã¶ã¼ã§åä½ãã¾ãã2015å¹´7æä»¥éããã¹ã¦ã®ãã©ã¦ã¶ã¼ã§å©ç¨å¯è½ã§ãã
children ã¯èªã¿åãå°ç¨ã®ããããã£ã§ãçãã HTMLCollection ã§å¼ã³åºãããè¦ç´ ã®åè¦ç´ ããã¹ã¦è¿ãã¾ãã
Element.children ã¯è¦ç´ ã®ãã¼ãããå«ã¿ã¾ããããã¹ã¦ã®åãã¼ããä¾ãã°ããã¹ããã³ã¡ã³ããã¼ããªã©ãåå¾ããã«ã¯ã Node.childNodes ã使ç¨ãã¦ãã ããã
å¤
çãã HTMLCollection ã§ã node ã®åã® DOM è¦ç´ ã®é åºä»ãã³ã¬ã¯ã·ã§ã³ãè¿ãã¾ããã³ã¬ã¯ã·ã§ã³ã® item() ã¡ã½ãããã JavaScript ã®é
åã¹ã¿ã¤ã«ã®è¨æ³ã使ã£ã¦ãã³ã¬ã¯ã·ã§ã³å
ã®åã
ã®åãã¼ãã«ã¢ã¯ã»ã¹ãããã¨ãã§ãã¾ãã
ãã¼ããåè¦ç´ ãæããªãå ´åã children ã¯è¦ç´ ãå«ã¾ããlength 㯠0 ã§ãã
ä¾
const myElement = document.getElementById("foo");
for (const child of myElement.children) {
console.log(child.tagName);
}
仿§æ¸
| 仿§æ¸ |
|---|
| DOM > # ref-for-dom-parentnode-childrenâ > |