属性の存在を確認
属性の存在を確認するには、element.hasAttributeメソッドを使用します。
構文
var result = element.hasAttribute(attribute name);
						引数
| 引数名 | 型 | 説明 | |
|---|---|---|---|
| 第一引数 必須  | 
									attribute name | string | 確認する属性名 | 
戻り値
属性が存在している場合はtrue、存在しない場合はfalseを返します。
サンプルコード
JavaScript
var sampleElement = document.getElementById('sample');
if (sampleElement.hasAttribute('href')) {
	alert('href属性が存在する');
} else {
	alert('href属性が存在しない');
}