Changing values in a TD tag

F

Filip Mato¹iæ

I wont to change the text (something) colour in a td tag.

<table> <tr><td>something</td></tr></table>
I have a form which validates and i wont to (if the field is incorrect)
change the txt colour in front
of the txt field . I dont know how to reach the text from javascript?
 
R

RobB

Filip Mato¹iæ said:
I wont to change the text (something) colour in a td tag.

<table> <tr><td>something</td></tr></table>
I have a form which validates and i wont to (if the field is incorrect)
change the txt colour in front
of the txt field . I dont know how to reach the text from javascript?

Well...for starters, it's not a 'tag' - not once it shows up on the
screen. By then it's an object, and you can 'get' it for programming
by several methods; probably the easiest is to simply id it, and use:

document.getElementById('cell id') //no spaces!

....and then change its style.color property to what you'd like.

document.getElementById('somecell').style.color = '#f00';
 
F

Filip Matosic

THX works fine, but i thought it was a tag, aren't all html elements tags
(TD, TABLE, TR .....). Do you mean that as an object its an instance of the
table?
 
M

Michael Winter

THX works fine, but i thought it was a tag, aren't all html elements
tags (TD, TABLE, TR .....).

If you want to be pedantic, no. See
Do you mean that as an object its an instance of the table?

Something like that. I think the emphasis was on the object model: once a
document has been parsed, its content is represented as a tree of objects
- elements, text nodes, etc.

In my opinion, the correct way to refer to something like TD is the "TD
(or table cell) element", unless you're referring to something more
specific, like the start tag of that element.

[snip]

Mike


Please don't top-post.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top