*新闻详情页*/>
日期:2020-12-11 类型:科技新闻 我要分享
关键词:如何制作微信小程序,微信小程序源码,小程序码生成,凡科网微信小程序,微信公众号小程序
本文关键详细介绍了HTML5 HTMLCollection和NodeList的差别详解,共享给大伙儿,实际以下:
获得
HTMLCollection 目标
getElementsByTagName() 方式返HTMLCollection目标。
HTMLCollection 目标相近包括 HTML 元素的1个数字能量数组。
留意:
NodeList 目标
绝大多数访问器的querySelectorAll()回到 NodeList 目标。
留意
HTMLCollection 与 NodeList 的差别
编码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF⑻"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <P>1</P> <P id="p2">2</P> <P>3</P> <P>4</P> <P>5</P> <script> // getElementsByTagName() 方式回到 HTMLCollection 目标。 const myCollection = document.getElementsByTagName('p'); console.log(myCollection) // 绝大多数访问器的 querySelectorAll() 回到 NodeList 目标。 const myNodeList = document.querySelectorAll("p"); console.log(myNodeList) console.log(myNodeList ===myCollection) //false console.log(myCollection.p2) // <P id="p2">2</P> console.log(myNodeList.p2) //undefine </script> </body> </html>
到此这篇有关HTML5 HTMLCollection和NodeList的差别详解的文章内容就详细介绍到这了,更多有关HTML5 HTMLCollection NodeList內容请检索脚本制作之家之前的文章内容或再次访问下面的有关文章内容,期待大伙儿之后多多适用脚本制作之家!
Copyright © 2002-2020 如何制作微信小程序_微信小程序源码_小程序码生成_凡科网微信小程序_微信公众号小程序 版权所有 (网站地图) 粤ICP备10235580号