ホーム HTML CSS XML JAVASCRIPT   PHP SQL MORE...   リファレンス 事例集    

XML DOM removeAttributeNode() メソッド


Element Object Reference Element オブジェクト

定義と用法

removeAttributeNode() メソッドは、指定した属性を削除します。

DTD に属性のデフォルト値が定義されている場合、デフォルト値を持つ新しい属性が直ちに現れます。

This function returns the removed attribute node.

構文

elementNode.removeAttributeNode(node)

パラメータ 説明
node 必須。削除するノード


次のコードは、loadXMLDoc() を使用して xmlDoc に "books.xml" をロードし、 全 <book> 要素から "category" 属性ノードを削除します:

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName('book');

for(i=0;i<x.length;i++)
{
attnode=x.item(i).getAttributeNode("category");
old_att=x.item(i).removeAttributeNode(attnode);
document.write("Removed attribute: " + old_att.name + "<br />");
}

出力:

Removed attribute: category
Removed attribute: category
Removed attribute: category
Removed attribute: category

試してください »

Element Object Reference Element オブジェクト