DHTML
  Home arrow DHTML arrow Page 7 - Rough Guide To The DOM (part 1)
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DHTML

Rough Guide To The DOM (part 1)
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 10
    2001-04-09


    Table of Contents:
  • Rough Guide To The DOM (part 1)
  • Back To Basics
  • Navigating The Family Tree
  • What's In A Name?
  • Ducks In A Row
  • Changing Things Around
  • Alternatives
  • Shazam!

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Rough Guide To The DOM (part 1) - Alternatives
    ( Page 7 of 8 )

    An alternative way of obtaining (and setting) attribute values is via the attributes[] collection, which is essentially an array containing a list of all the attribute-value pairs for a specific tag. I've modified the previous example to illustrate how this works - uncomment the various alert()s to see the values of the different properties.

    <html><head></head><body id="body" bgcolor="white"><font face="Arial" size="2">This stuff is giving me a headache already!</font> <script language="JavaScript"> // get to the <font> tag var fontObj = document.getElementById("body").childNodes[0]; // return the number of attributes of the <font> tag // or the length of the attributes[] collection // returns 2 // alert(fontObj.attributes.length); // returns the name of the first attribute - "face" // alert(fontObj.attributes[0].name); // returns the value of the first attribute - "Arial" // alert(fontObj.attributes[0].value); // changes the value of the first attribute to "Verdana" fontObj.attributes[0].value = "Verdana"; // returns the new value of the first attribute - "Verdana" // alert(fontObj.attributes[0].value); </script> </body> </html>


     
     
    >>> More DHTML Articles          >>> More By Vikram Vaswani, (c) Melonfire
     

       

    DHTML ARTICLES

    - Rough Guide To The DOM (part 2)
    - Rough Guide To The DOM (part 1)
    - Filters And Transitions In IE5
    - Understanding Embedded Fonts




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT