HTML DOM anchors 集合
Document 对象
定义和用法
anchors集合返回了当前页面的所有超级链接数组 。
语法
document.anchors[].property
浏览器支持
所有主要浏览器都支持 anchors 集合
实例
实例 1
返回文档的链接数:
锚的数量:
document.write(document.anchors.length);
以上实例输出结果:
锚的数量: 3
尝试一下 »
实例 2
返回文档中第一个超级链接的锚文本:
文档中第一个锚:
document.write(document.anchors[0].innerHTML);
以上实例输出结果:
文档中第一个锚: HTML 教程
尝试一下 »
Document 对象