Results 1 to 9 of 9

Thread: alternate row colors in a list

  1. #1
    Join Date
    Aug 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default alternate row colors in a list

    hello, I'm trying to alternate row colors, but the examples I can find online require you to use tables...

    im looking for something, like js, to alternate row colors in a list. for example:

    Code:
    <div id="list">
    <ul>
         <li>item 1</li>
         <li>item 2</li>
         <li>item 3</li>
         <li>item 4</li>
         <li>item 5</li>
    </ul>
    </div>
    the list items in the id "list" will have alternating colors. is there anything like this out there? or am i stuck with tables.

    thanks

  2. #2
    Join Date
    Aug 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

  3. #3
    Join Date
    Jun 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    If you ask me, you'd be better off if you Highlight Table Cells.

    Although personally I don't even use a script for that. I just write this in every TR (which is more annoying than the script but still beats using a long script):
    HTML Code:
    <tr onMouseOver=this.className='trGridHoov' onMouseOut=this.className='trGrid'>
    And the CSS is:
    HTML Code:
    <style type="text/css"><!--
    .trGrid { background-color: white}
    .trGridHoov { background-color: #fef5d8}
    --></style>

  4. #4
    Join Date
    Aug 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by lwc View Post
    If you ask me, you'd be better off if you Highlight Table Cells.

    Although personally I don't even use a script for that. I just write this in every TR (which is more annoying than the script but still beats using a long script):
    HTML Code:
    <tr onMouseOver=this.className='trGridHoov' onMouseOut=this.className='trGrid'>
    And the CSS is:
    HTML Code:
    <style type="text/css"><!--
    .trGrid { background-color: white}
    .trGridHoov { background-color: #fef5d8}
    --></style>
    there's a reason why I don't like using tables, and that's because of seo purposes. and I already know about your code, however, it is not any easier and involves you to code each table row by hand, which is not very effective and can only be used for static html pages.

  5. #5
    Join Date
    Jun 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Why do you quote my entire post if you post directly after me?

    Anyway, it's not true. You can use code (even Javascript) to build dynamic tables.

    For example, I just use:
    HTML Code:
    build(contents of column1-row 1, contents of column1-row 2)
    build(contents of column2-row 1, contents of column2-row 2)
    ...
    build(contents of column5-row 1, contents of column5-row 2)
    where "build" is a table building Javascript function that does the special TR thing automatically.

    Also, if you use this site's script, then by default it's not a manual work.
    Last edited by lwc; 06-22-2007 at 04:38 PM.

  6. #6
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    The less we use tables the better. I don't know why you are insisting on using tables?

  7. #7
    Join Date
    Jun 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Because I rather have dynamic highlighting than alternate row colors.

  8. #8
    Join Date
    Aug 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I really don't see how having the code below with a simple javascript:

    Code:
    <li>sdflskdflskdf</li>
    <li>sdflskdflskdf</li>
    <li>sdflskdflskdf</li>
    <li>sdflskdflskdf</li>
    is harder than:

    Code:
    <tr onMouseOver=this.className='trGridHoov' onMouseOut=this.className='trGrid'>sdflskdflskdf</tr>
    <tr onMouseOver=this.className='trGridHoov' onMouseOut=this.className='trGrid'>sdflskdflskdf</tr>
    <tr onMouseOver=this.className='trGridHoov' onMouseOut=this.className='trGrid'>sdflskdflskdf</tr>
    <tr onMouseOver=this.className='trGridHoov' onMouseOut=this.className='trGrid'>sdflskdflskdf</tr>
    <tr onMouseOver=this.className='trGridHoov' onMouseOut=this.className='trGrid'>sdflskdflskdf</tr>
    LOL

  9. #9
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    Haha, abcdefGARY has a point. Tables are sometimes way too complex, when there are much easier ways to do the same thing. They have their place...but you can usually find a better way. I like the way you got on the other forum.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

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
  •