Changing values in a TD tag

Discussion in 'Javascript' started by Filip Mato¹iæ, Nov 30, 2004.

  1. 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?
    Filip Mato¹iæ, Nov 30, 2004
    #1
    1. Advertising

  2. Filip Mato¹iæ

    RobB Guest

    "Filip Mato¹iæ" <> wrote in message news:<cohjk5$j9p$>...
    > 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';
    RobB, Nov 30, 2004
    #2
    1. Advertising

  3. 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?
    "RobB" <> wrote in message
    news:...
    > "Filip Mato¹iæ" <> wrote in message
    > news:<cohjk5$j9p$>...
    >> 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';
    Filip Matosic, Dec 1, 2004
    #3
  4. On Wed, 1 Dec 2004 10:25:45 +0100, Filip Matosic <> wrote:

    > 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
    <URL:http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2> for a complete
    description of the various mark-up components.

    > 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.

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
    Michael Winter, Dec 1, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jstack
    Replies:
    1
    Views:
    599
    Tor Iver Wilhelmsen
    Jul 4, 2003
  2. kishan bisht

    struts tag inside a tag

    kishan bisht, Jul 8, 2003, in forum: Java
    Replies:
    1
    Views:
    1,483
    Wendy S
    Jul 9, 2003
  3. shahbaz
    Replies:
    0
    Views:
    896
    shahbaz
    Oct 27, 2003
  4. RC
    Replies:
    2
    Views:
    425
    Malte
    May 10, 2005
  5. shruds
    Replies:
    1
    Views:
    778
    John C. Bollinger
    Jan 27, 2006
Loading...

Share This Page