中文字幕一区二区人妻电影,亚洲av无码一区二区乱子伦as ,亚洲精品无码永久在线观看,亚洲成aⅴ人片久青草影院按摩,亚洲黑人巨大videos

HTML DOM scripts 集合

Document 對(duì)象參考手冊(cè) Document 對(duì)象

實(shí)例

查看文檔中有多少個(gè) <script> 元素:

var x = document.scripts.length;

運(yùn)行代碼 ?

定義與用法

scripts 集合返回文檔中所有 <script> 元素的集合。

注意: 元素在集合中的排序是它們?cè)谠创a中的順序。

提示: 相關(guān)內(nèi)容 Script 對(duì)象。


瀏覽器支持

表格中的數(shù)字表示支持該集合的第一個(gè)瀏覽器的版本號(hào)。

集合
scripts Yes Yes 9.0? Yes Yes

語法

document.scripts

屬性

屬性 描述
length 返回集合中 <script> 元素的個(gè)數(shù)。

提示: 這是一個(gè)只讀屬性。

方法

方法 描述
[index] 返回集合中指定索引(從 0 開始)的 <script> 元素。

注意: 如果索引值超出范圍返回 null。
item(index) 返回集合中指定索引(從 0 開始)的 <script> 元素。

注意: 如果索引值超出范圍返回 null。
namedItem(id) 回集合中指定 id 的 <script> 元素。

注意: 如果 id 不存在返回 null。

技術(shù)細(xì)節(jié)

DOM 版本: Core Level 3 Document Object
返回值: 一個(gè) HTMLCollection 對(duì)象, 表示文檔中所有的 <script> 元素。集合中元素的排序是根據(jù)源碼中的順序排列的。

更多實(shí)例

實(shí)例

[index]

獲取文檔中第一個(gè)(索引為 0) <script> 元素的內(nèi)容:

var x = document.scripts[0].text;

運(yùn)行代碼 ?

實(shí)例

item(index)

獲取文檔中第一個(gè)(索引為 0) <script> 元素的內(nèi)容:

var x = document.scripts.item(0).text;

運(yùn)行代碼 ?

實(shí)例

namedItem(id)

獲取 id="json" 的 <script> 元素的內(nèi)容:

var x = document.scripts.namedItem("json").text;

運(yùn)行代碼 ?

實(shí)例

遍歷文檔中所有的 <script> 元素,并輸出每個(gè) <script> 元素的 id:

var x = document.scripts; var txt = ""; var i; for (i = 0; i < x.length; i++) { txt = txt + x[i].id + "<br>"; }

運(yùn)行代碼 ?

相關(guān)文章

JavaScript 參考手冊(cè): HTML DOM Script 對(duì)象

HTML 教程: HTML 腳本

HTML 參考手冊(cè): HTML <script> 標(biāo)簽


Document 對(duì)象參考手冊(cè) Document 對(duì)象

其他擴(kuò)展