Interface Attr
The Attr
interface represents an attribute in an Element
object. Typically
the allowable values for the attribute are defined in a schema associated with the document.
Attr
objects inherit the Node
interface, but since they are not actually
child nodes of the element they describe, the DOM does not consider them part
of the document tree. Thus, the Node
attributes parentNode
, previousSibling
and nextSibling
have a null
value for Attr
objects. The DOM takes the
view that attributes are properties of elements rather than having a separate
identity from the elements they are associated with; this should make it more
efficient to implement such features as default attributes associated with all
elements of a given type. Furthermore, Attr
nodes may not be immediate children
of a DocumentFragment
. However, they can be associated with Element
nodes
contained within a DocumentFragment
. In short, users and implementors of the
DOM need to be aware that Attr
nodes have some things in common with other
objects inheriting the Node
interface, but they also are quite distinct.
Template arguments
interface Attr(DOMString);
Properties
Name | Type | Description |
---|---|---|
isId
[get]
|
bool |
Returns whether this attribute is known to be of type ID (i.e. to contain
an identifier for its owner element) or not. When it is and its value is
unique, the ownerElement of this attribute can be retrieved using the method
Document .
|
name
[get]
|
DOMString |
Returns the name of this attribute. If Node is different from
null , this attribute is a qualified name.
|
ownerElement
[get]
|
DOMImplementation |
The Element node this attribute is attached to or null if this attribute is not in use.
|
schemaTypeInfo
[get]
|
XMLTypeInfo!DOMString |
The type information associated with this attribute. While the type information
contained in this attribute is guarantee to be correct after loading the
document or invoking Document , schemaTypeInfo may
not be reliable if the node was moved.
|
specified
[get]
|
bool |
true if this attribute was explicitly given a value in the instance document,
false otherwise. If the application changed the value of this attribute
node (even if it ends up having the same value as the default value) then
it is set to true . The implementation may handle attributes with default
values from other schemas similarly but applications should use Document
to guarantee this information is up-to-date.
|
value
[get, set]
|
DOMString |
On retrieval, the value of the attribute is returned as a DOMString .
Character and general entity references are replaced with their values.
See also the method getAttribute on the Element interface.
On setting, this creates a Text node with the unparsed contents of the
string, i.e. any characters that an XML processor would recognize as markup
are instead treated as literal text.
See also the method Element .
|
Authors
Lodovico Giaretta
Copyright
Copyright Lodovico Giaretta 2016 --