XML DOM isId 屬性


Attr 對象參考手冊 Attr 對象

定義和用法

isId 屬性在屬性是 ID 類型時返回 true(例如,包含了其所屬的元素的識別字),否則返回 false。

語法

attrObject.isId


實例

下麵的代碼片段使用 loadXMLDoc() 把 "books.xml" 載入 xmlDoc 中,並返回 category 屬性是否是 <book> 元素的 ID 屬性:

實例

xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.getElementsByTagName('book'); for(i=0;i<x.length;i++) { document.write(x.item(i).attributes[0].isId); document.write("<br>"); }

上面的代碼將輸出:

false


Attr 對象參考手冊 Attr 對象