Export (0) Print
Expand All
1 out of 4 rated this helpful - Rate this topic

clearAttributes method

Removes all attributes and values from the object.

Syntax

object.clearAttributes()

Parameters

This method has no parameters.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information

There are no standards that apply here.

Remarks

The clearAttributes method clears only persistent HTML attributes. The ID attribute, styles, and script-only properties are not affected.

Examples

This example uses the clearAttributes method to remove user-defined attributes from an element.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/clearAttributes.htm


<script type="text/javascript">
  function fnClear() {
    oSource.children[0].clearAttributes();
  }
</script>
<span ID=oSource>
<div
   id="oDiv"
   attribute1="true"
   attribute2="true"
   onclick="alert('click');"
   onmouseover="this.style.color='#0000FF';"
   onmouseout="this.style.color='#000000';"
>
This is a sample <b>DIV</b> element.
</div>
</span>
<input
   type="button"
   value="Clear Attributes"
   onclick="fnClear()"
>

See also

a
abbr
acronym
address
applet
area
article
aside
b
base
baseFont
bgSound
big
blockQuote
body
br
button
caption
center
cite
code
col
colGroup
comment
custom
dd
del
dfn
dir
div
dl
dt
em
embed
fieldSet
figcaption
figure
font
footer
form
frame
frameSet
head
header
hgroup
hn
hr
html
i
iframe
img
input type=button
input type=checkbox
input type=email
input type=file
input type=hidden
input type=image
input type=number
input type=password
input type=radio
input type=range
input type=reset
input type=search
input type=submit
input type=tel
input type=text
input type=url
ins
isIndex
kbd
label
legend
li
link
listing
map
mark
marquee
menu
nav
nextID
noBR
noFrames
noScript
object
ol
option
p
plainText
pre
q
rt
ruby
s
samp
script
section
select
small
span
strike
strong
style
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
title
tr
tt
u
ul
var
wbr
xml
xmp
Reference
mergeAttributes
Conceptual
About the W3C Document Object Model

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.