Name

Document.createAttribute( ): create a new Attr node — DOM Level 1 Core:

Synopsis

Attr createAttribute(Stringname)
    throws DOMException;

Arguments

name

The name for the newly created attribute.

Returns

A newly created Attr node with its nodeName property set to name.

Throws

This method throws a DOMException with a code of INVALID_CHARACTER_ERR if name contains an illegal character.

See Also

Attr, Element.setAttribute( ), Element.setAttributeNode( )

Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.