The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery tr:even

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #33953

    hi guys,

    if you look at

    you will see that 3rd table named “Bankovní spojení”
    has wrong even colour

    it should start white, gray, white, …
    but starts as gray :(

    I used

    I have no .class or ID there, pure HTML targeted via jQuery
    can’t really figure it out


    Perhaps the theads have something to do with it. Try

    $("tbody tr:even").addClass('even');

    (I used addClass() because I think it’s best to keep styling out of js)


    In fact the theads do come into play. Using tr:even finds every other row in the entire document – its not relative to an individual table. Your second table only ‘works’ because of the number of rows in the first table. Here’s the simple solution:

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.