Availability
DOM Level 1 Core
Synopsis
Attr setAttributeNode(Attr newAttr)
throws DOMException;
Arguments
newAttr
The Attr node that represents the attribute to be added or whose
value is to be modified.
Returns
The Attr node that was replaced by
newAttr, or null if no
attribute was replaced.
Throws
This method may throw a DOMException with a code
of the following values:
INUSE_ATTRIBUTE_ERR
newAttr is already a member of the
attribute set of some other Element node.
NO_MODIFICATION_ALLOWED_ERR
The Element node is read-only and does not allow modifications to its
attributes.
WRONG_DOCUMENT_ERR
newAttr has a different
ownerDocument property than the Element on which
it is being set.
Description
This method adds a new Attr node to the set of attributes of an
Element node. If an attribute with the same name already exists for
the Element, newAttr replaces that
attribute, and the replaced Attr node is returned. If no such
attribute already exists, this method defines a new attribute for the
Element.
It is usually easier to use setAttribute( )
instead of setAttributeNode( ). However, you
should use setAttributeNode( ) when you need to
define an attribute whose value contains an entity reference for an
XML document.
See Also
Attr, Element.setAttribute( )
•
Table of Contents
•
Index
•
Reviews
•
Examples
•
Reader Reviews
•
Errata
JavaScript: The Definitive Guide, 4th Edition
By
David Flanagan
Publisher
: O'Reilly
Pub Date
: November 2001
ISBN
: 0-596-00048-0
Pages
: 936
Slots
: 1
This fourth edition of the definitive reference to
JavaScript, a scripting language that can be embedded
directly in web pages, covers the latest version of the
language, JavaScript 1.5, as supported by Netscape 6 and
Internet Explorer 6. The book also provides complete
coverage of the W3C DOM standard (Level 1 and Level 2),
while retaining material on the legacy Level 0 DOM for
backward compatibility.