XML DOM removeAttribute() メソッド
Element オブジェクト
定義と用法
removeAttribute() メソッドは、指定した属性を削除します。
DTD に属性のデフォルト値が定義されている場合、デフォルト値を持つ新しい属性が直ちに現れます。
構文
elementNode.removeAttribute(name)
|
パラメータ |
説明 |
name |
必須。削除する属性を指定 |
例
次のコードは、loadXMLDoc() を使用して xmlDoc に
"books.xml" をロードし、
全 <book> 要素から "category" 属性を削除します:
例
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
document.write(x[0].getAttribute('category'));
document.write("<br />");
x[0].removeAttribute('category');
document.write(x[0].getAttribute('category'));
|
試してください »
|
Element オブジェクト
|