This is a new feature introduced with the DOM level 1 standard and currently available only in fully DOM compliant browsers.
The example function shows how a new attribute object can be created and set on an element. Because this is standardized at the DOM document level and is not dependent on HTML, it could work in non-web browser implementations.
This is where browser implementations of DOM functionality tend to blur the facts slightly. DOM describes a generic Document and then sub-classes that to describe an HTMLDocument. Browsers merge the two areas of functionality and simply call it a Document.
// A code fragment that creates an attribute and sets it on // an element object that is passed in: function attachMyAttrib(anElement, aName, aValue) { var myNewAttr = createAttribute(aName); var myOldAttr = anElement.setAttributeNode(myAttr); }
See also: | Attr object, Attribute object |
Prev | Home | Next |
Document.cookie | Up | Document.createCDATASection() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |