XML DOM textContent 屬性
Attr 對象
定義和用法
textContent 屬性設(shè)置或返回屬性的文本內(nèi)容。
語法
實例
下面的代碼片段使用 loadXMLDoc() 把 "books.xml" 載入 xmlDoc 中,并返回 category 屬性的文本內(nèi)容:
實例
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
for(i=0;i<x.length;i++)
{
document.write(x.item(i).attributes[0].textContent);
document.write("
");
}
輸出:
COOKING
CHILDREN
WEB
WEB
嘗試一下 ?
嘗試一下 Demos
textContent - 設(shè)置屬性的文本內(nèi)容
Attr 對象
更多建議: