XML DOM specified 屬性


Attr 對象參考手冊 Attr 對象

定義和用法

如果在文檔中設置了屬性值,則 specified 屬性返回 true,如果是 DTD/Schema 中的默認值,則返回 false。

語法

attrObject.specified


實例

下麵的代碼片段使用 loadXMLDoc() 把 "books.xml" 載入 xmlDoc 中,並顯示 category 屬性的名稱和值:

實例

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

輸出:

true
true
true
true


Attr 對象參考手冊 Attr 對象