You are here: Reference > JavaScript > client-side > style handling > methods > removeAttribute (runtimeStyle, style)
removeAttribute method (runtimeStyle, style)
| A A | Font size |
|
|
Share |
|
Removes the specified property from the current style object.
In Firefox, Safari and Opera the removeProperty method provides similar functionality.
- To set a value for a style property, use the setAttribute method in Internet Explorer and the setProperty method in Firefox, Opera and Safari.
- To get the value of a style property, use the getAttribute method in Internet Explorer and the getPropertyValue method in Firefox, Opera and Safari.
Syntax:
You can find the related objects in the Supported by objects section below.
Parameters:
| Required. String that specifies the name of the style property to remove. Use the name of the corresponding JavaScript property (camelCase name) instead of the name of the CSS property. The corresponding JavaScript property names can be found on the pages for the CSS properties. | ||||||||||||||||||||
|
Optional. Integer that specifies the case-sensitivity for the name of the property.
This parameter is only supported by Internet Explorer earlier than version 8.
The name is not case sensitive since version 8.
In earlier versions, the following values are supported:
|
Return value:
Boolean. One of the following values:
| The property was not removed. | |
| The property was removed. |
Example HTML code 1:
This example illustrates the use of the removeAttribute method:
|
|
||||
<head> <script> function RemoveBGColor (button) { if (button.style.removeAttribute) { button.style.removeAttribute ("backgroundColor"); } else { button.style.removeProperty ("background-color"); } } </script> </head> <body> <button onclick="RemoveBGColor (this);" style="background-color:red;">Remove my background color!</button> </body> |
||||
|
||||
|
Did you find this example helpful?
|
Supported by objects:
htmlElement.runtimeStyle, htmlElement.style
HTML elements:
a, abbr, acronym, address, applet, area, b, base, basefont, bdo, bgsound, big, blink, blockquote, body, br, button, caption, center, cite, code, col, colgroup, comment, dd, del, dfn, dir, div, dl, dt, em, embed, fieldset, font, form, frame, frameset, h1, h2, h3, h4, h5, h6, head, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:hidden, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isindex, kbd, keygen, label, legend, li, link, listing, map, marquee, menu, meta, nobr, noframes, noscript, object, ol, optgroup, option, p, param, plaintext, pre, q, rt, ruby, 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, xml, xmp
Related pages:
External links:
User Contributed Comments

