codecamp

XML DOM specified 属性——Attr 对象

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("
");
}

输出:

true
true
true
true

尝试一下 »

Attr 对象参考手册 Attr 对象
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }