removeAttributeメソッド

removeAttributeメソッドは、任意のタグから指定された 属性を削除します。

構文

javascript要素.removeAttribute(属性名);

例

要素からvalue属性を削除してみましょう:

html<input id="elem" value="abcde">
javascriptlet elem = document.querySelector('#elem');
elem.removeAttribute('value');

HTMLコードは次のようになります(value属性が消えます):

html<input id="elem">

関連項目