How to cycle through TR tags in TABLE

hi there,

I have the following table
<table id="mytable">
      <tr id="myHeader">
      <tr id="row_0">
      <tr id="row_1">
      <tr id="row_2">
      <tr id="row_3">
      <tr id="row_4">
      <tr id="row_5">

How with javascript can i cycle through the rows? I wish to apply a background style on some rows.

I have tried various methods which i wont post here to clutter. I prefer a solution which does not cycle through all controls on the page, rather, just the rows of this table if possible.

This is for an intranet which is IE only, so an IE solution is fine.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

var tbl = document.getElementById("myTable");
var thead = tbl.firstChild;//IE implicitly adds thead element
var tr = thead.getElementsByTagName("tr");
for(var i=0, limit=tr.length; i < limit; ++i )
Not sure, but I believe this would have worked as well. Give them both a try:
var tbl = document.getElementById("myTable");
var tr = tbl.getElementsByTagName("tr");
for(var i=0, limit=tr.length; i < limit; ++i )

PS: change your id on your table to "myTable" uppercase "T" since that's what I used on the code

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ValimaiAuthor Commented:
bravo, thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.