ZVON > References > DOM2 Reference

removeAttribute (method )

Owning interface and usage:  
Element.removeAttribute(name)

Member of these other interfaces:  
none

Description:  
Removes an attribute by name.

Parameters:  
DOMString name  -  The name of the attribute to remove.

Returns:  
nothing

Exceptions:  
DOMException NO_MODIFICATION_ALLOWED_ERR
Raised if this node is readonly.

Note:  
If the removed attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.


Example:
Text in the first DIV.
Some text in the second DIV.
Some text and element in the third DIV.
We can try another elements. It will be much more interesting.
Text in the last DIV.
Source:
   <div id="doc">
     <div>
       Text in the first DIV.
     </div>
     <div id="DDD" class="secondClass">
       Some text in the second DIV.
     </div>
     <div class="thirdClass">
       Some text and <span id="SSS">element</span> in the third DIV.
     </div>
     <div class="fourthClass">
       We can try <i>another elements</i>.
       It will be much more <b>interesting</b>.
     </div>
     <div>
       Text in the last DIV.
     </div>
   </div>
     
JavaScript:
  var main = document.getElementById('doc');
  main.removeAttribute('id');
  var output = main.getAttribute('id');
Output:
desired your browser
output: