Programmer's Guide > Interfaces > W3C Document interface > createAttribute method
  
createAttribute method
Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttributeNode method.
To create an attribute with a qualified name and namespace URI, use the createAttributeNS method.
createAttribute(name )
Parameters
Stringname
The name of the attribute.
Returns
Attr. A new Attr object with the nodeName attribute set to name, and localName, prefix, and namespaceURI set to null. The value of the attribute is the empty string.
Throws
DOMException
INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.