ZVON > References > DOM1 Reference

createAttribute (method)

Owning interface and usage:  
Document.createAttribute(name)

Member of these other interfaces :  
none

Description:  
Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttribute() method.

Parameters:  
DOMString name  -  The name of the attribute.

Returns:  
Attr -  A new Attr object.

Exceptions:  
DOMException INVALID_CHARACTER_ERR
Raised if the specified name contains an invalid character.


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');
  var attr = document.createAttribute('temp');
  attr.value = 'temporary';
  main.setAttributeNode(attr);
  var output = main.getAttribute('temp');
Output:
desired your browser
temporary



_____________________________________________
Reference Search | Sitemap | XML Glossary       ZVON | Systinet




Related sites:
  • dotNet Slackers - Your latest resource for ASP.NET
  • Dotnet Spider - Outsourcing and Offshore software development in India
  • XML - Xselerator, XSL Editor, BizTalk Utilities, XML Tutorials, Learn XML
  • Planet Source Code - The largest public source code database on the Internet
UNLIMITED Web Hosting by HostDepartment Alojamiento Web UK Domain Names glossary for conference call answering service
MSN VoIP Internettelefonie Hosted Exchange, SDSL VoIP Internettelefonie AT VoIP Internettelefonie DE