Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOM

Status
Not open for further replies.

zwarte

Programmer
Joined
Jul 5, 2002
Messages
9
Location
BR
Hello Board,

Please help me if you can. Here is what I am trying to do. I want to access the properties of the BGCOLOR of the <TD> using the DOM. Here is an example.

<td id=&quot;1&quot; bgcolor=&quot;#FFFFFF&quot;> <--- with ID.

Here is how I am trying to access it:

<script language=&quot;JavaScript&quot;>
document.all.1.bgColor = &quot;black&quot;;
</script>

I am just learning please advise.

-Zwarte
 
when specifying ids do not start them with a number, first character whould by alphabetic character. Also, you dont need to go through the all collection when dealing with ids.


In IE you can simply say
ID.bgColor=&quot;black&quot;

in N6 you would say
document.getElementById(&quot;ID&quot;).bgColor=&quot;black&quot;

so change the id of your cell to &quot;C1&quot; say and rewrite your code to

C1.bgColor=&quot;black&quot;

for IE
 
You are very cool. Thanks.

-Jay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top