hasAttributes()

XML DOM hasAttributes() metodi


❮ Element obyekti

Misol

Quyidagi kod fragmenti "books.xml" faylini xmlDoc’ga yuklaydi va birinchi <book> elementida biror atribut bor-yo‘qligini tekshiradi:

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

Natija:

true
O‘zingiz sinab ko‘ring »

Ta’rif va qo‘llanilishi

Agar joriy element tugunida biror atribut bo‘lsa, hasAttributes() metodi TRUE, aks holda FALSE qaytaradi.

Sintaksis

hasAttributes()

❮ Element obyekti

W3Schools Pathfinder

Yutuqlaringizni kuzating – bu bepul!