XML DOM hasAttributes() 方法——Element 對象

2018-08-05 16:37 更新

XML DOM hasAttributes() 方法


Element 對象參考手冊 Element 對象

定義和用法

hasAttributes() 方法在當前元素節(jié)點擁有屬性時返回 TRUE,否則返回 FALSE。

語法

hasAttributes()


實例

下面的代碼片段使用 loadXMLDoc() 把 "books.xml" 載入 xmlDoc 中,并檢查返回第一個 <book> 元素是否擁有屬性:

實例

xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book')[0];

document.write(x.hasAttributes());

輸出:

true

嘗試一下 ?

Element 對象參考手冊 Element 對象
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號