Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    getElementsByTagName - Loop

    Quick question...how would I make the below code only loop every other one

    Code:
    function change(id)
    {
        var marked = document.getElementsByTagName('TD');
        for(var k=0,mark; mark=marked[k]; k++)
        {
            if(mark.name==id)
                mark.className = 'test';
        }
    }
    ...James

  • #2
    New Coder
    Join Date
    May 2003
    Location
    New Jersey
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Change k++ to k = k + 2

  • #3
    New Coder
    Join Date
    Apr 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! When I first tried that route I went K = +2 lol know i know where I went wrong. Thanks again


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •