tags:

views:

23

answers:

1

EDIT
Hi. I got 1 page(html) where I got a couple of tables. I want so within each table every odd row got a class. My problem is it only take the first table and go on with the odd on to the others to, when it just suppose to do that with in that one table, stop, start over with the next table. like this table, every other row, add class, next table, every other row, add class. NOW it's like table, every other row for all the tables. U know?

EDIT Reason I want it to go into each table is because this is a menu and each menu got this structure.

table
1:st tr, title
2:nd tr, menu
3:rd tr, menu
and so on


If I just do a tr:odd it will just keep going with addClass and on the next table it will mess up my title, you know?

I tried two different ways both wont work the way I would like them to. regular and each

$.each( {'.tableMenu'}, function () {
            $('table.tableMenu tr:odd').addClass('tableSubMenu');
});


$('table.tableMenu tr:odd').addClass('tableSubMenu');
+2  A: 

You forgot to add each loop.

$('table.tableMenu').each(function(){
    $(this).find("tr:odd").addClass('tableSubMenu');
});

See working demo http://www.jsfiddle.net/MpQth/

Kai
for the love of God!... finally someone underst00d the OP! +1
Reigel
Thanks that was just what I was looking for. I tried the each, don't know what I was missing in mine? maybe it was that I had table.tableMenu in there aswell? anyway thanks again
Dejan.S
Gah I'm so late :) An answer has been accepted already :)
Marko