removeAttribute method
Removes an attribute from an object.
![]() |
Syntax
object.removeAttribute(strAttributeName, lFlags)Parameters
- strAttributeName [in]
-
Type: String
String that specifies an attribute name.
- lFlags [in, optional]
-
Type: Integer
Integer that specifies whether to use a case-sensitive search to locate the attribute. Can be one of the following values:
Return value
Type: Boolean
Boolean. Returns one of the following possible values:| Return value | Description |
|---|---|
|
The attribute was successfully removed. |
|
The attribute was not removed. |
Standards information
- Document Object Model (DOM) Level 2 HTML Specification, Section 1.6.5
Remarks
Windows Internet Explorer 8 and later. IE8 Standards mode enables several enhancements to the setAttribute, getAttribute, and removeAttribute methods that are not available when pages are displayed in earlier document modes:
- The strAttributeName parameter requires the name of the desired content attribute and not the Document Object Model (DOM) attribute.
For example, in IE8 mode, this method no longer requires strAttributeName to be
"className"when setting, getting, or removing a CLASS attribute. Earlier versions of Windows Internet Explorer and Internet Explorer 8 in compatibility mode still require strAttributeName to specify the corresponding DOM property name. - The strAttributeName parameter is not case sensitive. As a result, the lFlags parameter is no longer supported and should not be used.
- The methods support event handlers. For example, the following code example defines an event handler to call a function called SomeFunction when the body of the page is loaded.
document.body.setAttribute('onload', 'SomeFunction()');
removeAttribute always returns S_OK as an HRESULT value. Check the pfSuccess parameter to determine if the attribute is successfully removed.
If your pages are displayed in IE5 (Quirks) mode or IE7 Standards mode, be careful when spelling attribute names. If two or more attributes have the same name—differing only in capitalization—and lFlags is set to 0, this method removes only the last attribute to be created with this name. All other attributes of the same name are ignored.
See also
- a
- address
- applet
- area
- b
- base
- baseFont
- bgSound
- big
- blockQuote
- body
- br
- button
- caption
- center
- cite
- code
- col
- colGroup
- comment
- custom
- dd
- dfn
- dir
- div
- dl
- dt
- em
- embed
- fieldSet
- font
- form
- frame
- frameSet
- head
- hn
- hr
- html
- i
- iframe
- img
- input type=button
- input type=checkbox
- input type=file
- input type=hidden
- input type=image
- input type=password
- input type=radio
- input type=reset
- input type=submit
- input type=text
- kbd
- label
- legend
- li
- link
- listing
- map
- marquee
- menu
- meta
- nextID
- noBR
- object
- ol
- option
- p
- plainText
- pre
- runtimeStyle
- s
- samp
- script
- select
- small
- span
- strike
- strong
- style
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- title
- tr
- tt
- u
- ul
- var
- wbr
- xmp
- Reference
- getAttribute
- setAttribute
Send comments about this topic to Microsoft
Build date: 6/20/2013


