SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Change BG Color of the row repeating in loop dynamically data

    Hi,
    I am having a single row which repeat dynamically.
    My issue is i want to make alternate colors in rows. (i.e white n gray)

    I can put the class for the row. but when it repeats it get the same bg color.

    How can i do the alternate thing.?

    Please Help

    Thanks
    Vikas

  2. #2
    Non-Member
    Join Date
    Apr 2011
    Location
    no fixed address
    Posts
    851
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    post the code that generates the rows

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by hatwal View Post
    Hi,
    I am having a single row which repeat dynamically.
    My issue is i want to make alternate colors in rows. (i.e white n gray)
    Have you tried using the CSS code that deals with odd/even rows?

    Code css:
    tr:nth-child(odd) {
        background-color:#fff;
    }
    tr:nth-child(even) {
        background-color:#ccc;
    }
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi i dont hv any idea how to use this..Can u give me any example for this?

    Quote Originally Posted by paul_wilkins View Post
    Have you tried using the CSS code that deals with odd/even rows?

    Code css:
    tr:nth-child(odd) {
        background-color:#fff;
    }
    tr:nth-child(even) {
        background-color:#ccc;
    }

  5. #5
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by hatwal View Post
    Hi i dont hv any idea how to use this..Can u give me any example for this?
    It looks like you are using CSS to create fake tables on your site. It is okay to use tables for tabular data, such as your list of cables and desktop accessories. It is even beneficial, in that achieving odd/even rows then becomes a simple effect to create.

    Code html4strict:
    <table>
        <thead>
            <tr>
                <th>Item #</th>
                <th>Description</th>
                ...
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>03153115</td>
                <td><a href="...">Belkin SuperSpeed USB 3.0 A to B (Male/Male) Cable 3</a></td>
                ...
            </tr>
            ...
        </tbody>
    </table>
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Tags for this Thread

Bookmarks

Posting Permissions

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