W3C home > Mailing lists > Public > www-svg@w3.org > February 2004

Re: Help accessing elements of elements using the DOM

From: Cameron McCormack <cam-www-svg@aka.mcc.id.au>
Date: Wed, 4 Feb 2004 15:09:11 +1100
To: www-svg@w3.org
Message-ID: <20040204040911.GA6887@mcc.id.au>

Hi Sam.

Samuel Goldenbaum:
> I am able to use the getElementById function to return the element with
> an id of 'level_7'. 
> 
> level  = document.getElementById('level_7');
> 
>  
> 
> I now need to get the element with an id of 'Colou1_1' and change some
> of its attributes.
> 
> color = level.getElementById('Colour1');
> 
>  
> 
> Yet this causes errors saying the object does not support this function?

Element ids are global, so there is no need to first get the 'level_7'
object and then get the 'Colour1' object.  Just do

  color = document.getElementByid('Colour1');

to get it.

Hope this helps,

Cameron

-- 
Cameron McCormack
|  Web: http://mcc.id.au/
|  ICQ: 26955922
Received on Tuesday, 3 February 2004 23:09:14 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:26 GMT