XML DOM isIdคุณสมบัติ
❮ Attr วัตถุ
ตัวอย่าง
โค้ดย่อยต่อไปนี้โหลด " books.xml " ลงใน xmlDoc และส่งกลับว่าแอตทริบิวต์หมวดหมู่เป็นแอตทริบิวต์ ID ขององค์ประกอบ <book> หรือไม่:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
xhttp.open("GET", "books.xml", true);
xhttp.send();
function myFunction(xml) {
var x, i, xmlDoc, txt;
xmlDoc = xml.responseXML;
txt = "";
x = xmlDoc.getElementsByTagName('book');
for(i = 0; i < x.length; i++) {
txt += x.item(i).attributes[0].isId + "<br>";
}
document.getElementById("demo").innerHTML = txt;
}
ความหมายและการใช้งาน
คุณสมบัติ isId ส่งกลับค่า จริง หากทราบว่าแอตทริบิวต์นั้นเป็นประเภท ID (เช่น มีตัวระบุสำหรับองค์ประกอบเจ้าของ) มิฉะนั้นจะส่งกลับค่าเท็จ
ไวยากรณ์
attrObject.isId
❮ Attr วัตถุ