XML DOM hasAttributes() ກົນລະບຽບ
ການອະທິບາຍ ແລະ ການນໍາໃຊ້
ຖ້າປະກອບພະຍາກອນມີຜົນກະທົບບໍ່: hasAttributes()
ກົນລະບຽບກັບ true ຖ້າບໍ່ມີ true.
ວິທີການ
hasAttributes()
ຄວາມຈິງ
ລະບຸການທີ່ລາວຈະ "books.xml" ຕິດຕັ້ງໃນ xmlDoc ແລະກວດກາວ່າປະກອບ <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 xmlDoc = xml.responseXML; var x = xmlDoc.getElementsByTagName('book')[0]; document.getElementById("demo").innerHTML = x.hasAttributes(); }