طريقة XML DOM hasAttributes()
التعريف والاستخدام
إذا كان العنصر الحالي يمتلك أي خصائص، فإن hasAttributes()
يستعيد الطريقة الصحيحة true، وإلا returns false.
النحو
hasAttributes()
مثال
الخطوط التالية ستقوم بتحميل "books.xml" إلى xmlDoc وتحقق مما إذا كان عنصر <book> الأول يمتلك أي خصائص:
var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { myFunction(this); x.hasAttributes(); }; xhttp.open("GET", "books.xml", true); xhttp.send(); function myFunction(xml) { var xmlDoc = xml.responseXML; var xmlDoc = xml.responseXML; var x = xmlDoc.getElementsByTagName('book')[0]; document.getElementById("demo").innerHTML = x.hasAttributes();