html的DOM中document對(duì)象anchors集合用法實(shí)例
更新時(shí)間:2015年01月21日 10:18:23 投稿:shichen2014
這篇文章主要介紹了html的DOM中document對(duì)象anchors集合用法,實(shí)例分析了anchors集合的功能及使用技巧,需要的朋友可以參考下
本文實(shí)例講述了html的DOM中document對(duì)象anchors集合用法。分享給大家供大家參考。具體分析如下:
anchors 集合可返回對(duì)文檔中所有 Anchor 對(duì)象的引用。
語法:
復(fù)制代碼 代碼如下:
document.anchors[]
例子:
復(fù)制代碼 代碼如下:
<html>
<body>
<a name="first">First anchor</a><br />
<a name="second">Second anchor</a><br />
<a name="third">Third anchor</a><br />
<br />
Number of anchors in this document:
<script type="text/javascript">
document.write(document.anchors.length)
</script>
</body>
</html>
<body>
<a name="first">First anchor</a><br />
<a name="second">Second anchor</a><br />
<a name="third">Third anchor</a><br />
<br />
Number of anchors in this document:
<script type="text/javascript">
document.write(document.anchors.length)
</script>
</body>
</html>
希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。
您可能感興趣的文章:
相關(guān)文章
JS根據(jù)年月獲得當(dāng)月天數(shù)的實(shí)現(xiàn)代碼
這篇文章主要介紹了JS根據(jù)年月獲得當(dāng)月天數(shù)的實(shí)現(xiàn)代碼,需要的朋友可以參考下2014-07-07javascript中的__defineGetter__和__defineSetter__介紹
這篇文章主要介紹了javascript中的__defineGetter__和__defineSetter__介紹,類似面向?qū)ο笳Z言中的get和set關(guān)鍵字,需要的朋友可以參考下2014-08-08瀏覽器環(huán)境下JavaScript腳本加載與執(zhí)行探析之defer與async特性
defer和async特性相信是很多JavaScript開發(fā)者"熟悉而又不熟悉"的兩個(gè)特性,從字面上來看,二者的功能很好理解,分別是"延遲腳本"和"異步腳本"的作用2016-01-01