DOM

Element.hasAttributes() メソッド

 編集:2022.09.22 by T.A.

[Edge]。→

element が属性を1つでも持っているか否かを Boolean で返します。

構文
element.hasAttributes()
element Element
戻り値

Boolean

HTML:

<SPAN id=IdTest>[SPAN要素<B>[B要素]</B>]</SPAN>

JavaScript:

D=IdTest.hasAttributes();   //=[boolean]:true
E=IdTest.firstElementChild; //SPAN要素の子要素を取得する。
D=E.hasAttributes();        //=[boolean]:false

テスト