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