了解NodeList、HTMLCollection以及NamedNodeMap的使用(代码)


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

<body>

<p>

  <a href="#" id="a1">1</a>

  <a href="a.html" name="a2">2</a>

</p>

</body>

<script>

    // 获取一个HTMLCollection对象

    var res = document.getElementsByTagName("a");

    console.log(res);

    console.log(res.item(0))

    console.log(res[0])

    console.log(res.namedItem('a1'))

    console.log(res.namedItem('a2'))

    // 结果如下图所示:

</script>

1.png

以上就是对了解NodeList、HTMLCollection以及NamedNodeMap的使用(代码)的全部介绍,如果您想了解更多有关HTML视频教程,请关注PHP中文网。

以上就是了解NodeList、HTMLCollection以及NamedNodeMap的使用(代码)的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

了解NodeList、htmlcollection以及namednodemap的使用(代码)

更多相关阅读请进入《NodeList》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...