removeAttribute (W3C DOM Core method)
example above removes the
href attribute from an
So if the element in that example referred to this HTML:
<a href="http://www.brothercake.com/" rel="me">brothercake</a>
Then the operation would result in this:
Remove an attribute with the specified name.
If the attribute has a specific default value in
this document type, removing the attribute should replace it with the
default value (as well as its corresponding
prefix if applicable).
removes non-namespaced attributes; to remove a namespaced attribute, use
the DOM 2
removeAttributeNS method instead.
Firefox, Safari and
Opera 9.5 when removing an attribute which has
a specific default value in this document type (such as the
shape attribute of an
element) the attribute is not replaced with the default (only
Opera 9.0 gets this right).
Internet Explorer in HTML, as with
getAttribute, this method is mapped to
properties, not attributes; so for some attributes you need to use the
property name, such as
className for a
class attribute and
htmlFor for a
getAttribute for more
Additionally, in Internet Explorer in
HTML using this method on a
attribute doesn't actually remove it; IE considers the value of a
style attribute to be a
style object, not a string, and using
removeAttribute has the effect of resetting all
the style properties to their default values, while retaining the object
itself. Using this method on an attribute which IE considers to have a
true value (such as
disabled, when defined) resets it to
false, and using it on an attribute IE considers to be
a number (such as
tabindex) or a function
(event-handling attributes such as
onclick) has no
effect at all.
implements a second argument to
removeAttribute, which is a case-sensitivity flag
that can take the value
0 (case-insensitive) or
1 (default, case-sensitive). This argument works as
expected in IE, and does not affect any other browser.
Internet Explorer also implements a
return value, which should be boolean
false according to whether the attribute was
successfully removed. However in practise, it returns
true whenever an attribute should have been
removed, even if it actually wasn't (because of one of the value type
caveats mentioned above).
There are no comments yet.