Metodo hasAttributes() DOM XML
Definizione e uso
Il metodo hasAttributes() restituisce true se un nodo ha qualsiasi attributo, altrimenti restituisce false.
Sintassi:
nodeObject.hasAttributes()
Esempio
In tutti gli esempi, utilizzeremo il file XML books.xmle la funzione JavaScript loadXMLDoc()。
Il seguente frammento di codice può restituire se il primo elemento <book> ha qualsiasi attributo:
xmlDoc=loadXMLDoc("books.xml");
var x=xmlDoc.getElementsByTagName('book')[0];
document.write(x.hasAttributes()
);
Output:
true