www.webdeveloper.com
Results 1 to 7 of 7

Thread: using JS to change multiple same-name IDs

  1. #1
    Join Date
    May 2005
    Location
    Dirty Jersey
    Posts
    1,400

    using JS to change multiple same-name IDs

    HI THERE

    so check it, i have this game server query thing im writing in PHP for a game called starsiege tribes.. ive spent so much time today doing the PHP that im getting a brainfreeze on how to do the following:

    in a given row, my table will always have 10 columns. 9 will have a style that i want to change. so i know i will need to assign the 9 the same ID. whenever there is a mouseover event on any one of the 9, i want the other 8 to all have their text color change to white. on mouse out, it goes back to what it was before. this gives me the effect of a highlight.

    how do i write this in JS? i know its simple, but right now ive OD'd on PHP and i just cant pull it out, or correctly phrase the question to the search bar. heck, even linking a previously answered question on this topic will help!

    thanks!!

  2. #2
    Join Date
    Jul 2005
    Location
    USA
    Posts
    3,910
    1) IDs should be unique. You could use a class instead.

    Class and ID Selectors
    When should I use a class and when should I use an ID?
    The Meaning of Semantics Take II: Naming Conventions for Class and ID in CSS
    Use class with semantics in mind

    Multiple elements may belong to the same class and an element may belong to multiple classes. The X/HTML class attribute's value may be a space separated list of classes.

    2) Why don't you set the background-color on the 10th column and just change the color of the <tr> for the other columns?
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions

    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

    Check out my blog.

  3. #3
    Join Date
    May 2005
    Location
    Dirty Jersey
    Posts
    1,400
    semantics. whatever. fine, ill use a class instead.

    how do i browse through all the class elements of name x on a page? whats the for loop look like?

  4. #4
    Join Date
    May 2005
    Location
    Dirty Jersey
    Posts
    1,400
    the bump.

  5. #5
    Join Date
    May 2005
    Location
    Dirty Jersey
    Posts
    1,400
    ...

  6. #6
    Join Date
    Jul 2005
    Location
    USA
    Posts
    3,910
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions

    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

    Check out my blog.

  7. #7
    Join Date
    May 2005
    Location
    Dirty Jersey
    Posts
    1,400
    thanks! i was confident someone had this info since it was easy!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles