Tutorial :select odd with several tables on the site?



Question:

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');  


Solution:1

You forgot to add each loop.

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

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


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »