XML DOM hasAttributes()メソッド
Node オブジェクト
定義と使い方
hasAttributes() メソッドは、ノードが属性を持つ場合は true を返し、それ以外の場合は false を返します。
構文
nodeObject.hasAttributes()
例
以下のコードスニペットは次を使用しますloadXMLDoc()「」を xmlDoc に読み込み、最初の <book> 要素が属性を持つかどうかを返します:
例
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book')[0];
document.write(x.hasAttributes());
x=xmlDoc.getElementsByTagName('book')[0];
document.write(x.hasAttributes());
出力:
true
試してみる »
Node オブジェクト その他の拡張