ZVON > References > DOM2 Reference

hasAttributes (method )

Owning interface and usage:  
Node.hasAttributes()

Member of these other interfaces:  
Attr, CDATASection, CharacterData, Comment, Document, DocumentFragment, DocumentType, Element, Entity, EntityReference, Notation, ProcessingInstruction, Text

Description:  
Returns whether this node (if it is an element) has any attributes.

Parameters:  
none

Returns:  
Boolean -  true if this node has any attributes, false otherwise.

Exceptions:  
none


Example:
Text in the first DIV.
Some text in the second DIV.
Some text and element in the third DIV.
We can try another elements. It will be much more interesting.
Text in the last DIV.
Source:
   <div id="doc">
     <div>
       Text in the first DIV.
     </div>
     <div id="DDD" class="secondClass">
       Some text in the second DIV.
     </div>
     <div class="thirdClass">
       Some text and <span id="SSS">element</span> in the third DIV.
     </div>
     <div class="fourthClass">
       We can try <i>another elements</i>.
       It will be much more <b>interesting</b>.
     </div>
     <div>
       Text in the last DIV.
     </div>
   </div>
     
JavaScript:
  var elem1 = document.getElementById('doc');
  var output1 = elem1.hasAttributes();
  var tmp = elem1.getElementsByTagName('div');
  var elem2 = tmp[tmp.length-1];
  var output2 = elem2.hasAttributes();
Output:
desired your browser
output1: true
output2: false