Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

removeNamedItem method

Removes an attribute specified with the name property from an element by using the attributes collection.

Document Object Model (DOM) Level 3 Core Specification, Section 1.4



var retval = attributes.removeNamedItem(bstrName);


bstrName [in]

Type: BSTR

A String that specifies the name of an attribute to remove.

Return value

Type: IHTMLDOMAttribute

Returns an attribute removed from the document if successful, otherwise null.

Standards information


An attribute that is removed with this method reverts to the default value of the attribute when applicable. This method returns a script error if the user attempts to remove a non-existent attribute node.

removeNamedItem was introduced in Microsoft Internet Explorer 6.


The following example shows how to use this method to remove an attribute from an element.

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

<!DOCTYPE html>

  <title>removeNamedItem Method Sample</title>

  <h1>removeNamedItem Method Sample</h1>
  <p>Hover over the below <strong>div</strong> to see the tooltip. Then, click 
    the <strong>div</strong> and hover over it again and note that the tooltip has been remove.</p>
  <div id="myDIV" 
    style="background-color: #96F; color: #FFF; border-style: outset; border-width: 4px; border-color: #FF6; width: 350px; text-align: center; cursor: pointer;" 
    title="THIS IS A TOOLTIP">
    Click this <strong>div</strong> to remove its tooltip attribute.
    document.getElementById('myDIV').addEventListener('click', removeAttrib, false);

    function removeAttrib(evt) {
      var myDIV = evt.target;

      var oAttrColl = myDIV.attributes;


See also




© 2015 Microsoft