Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Location
    Northwest Colorado
    Posts
    4,630

    Javascript Looping

    I have these tags, and I need to loop through them:

    <li id="nav1">
    <li id="nav2">
    <li id="nav3">

    Is this the correct code? I'm not certain about the "nav[i+1]" bit.

    for (i=0; i<3; i++) {
    x = document.getElementById("nav[i+1]");
    this.className+=" over";
    }
    Eric J. Bowman, principal
    Bison Systems Corporation coming soon: a new sig!
    I'm just a poor, unfrozen caveman Webmaster. Your new 'standards' frighten, and confuse me...

  2. #2
    for (i=1; i<4; i++) {
    x = document.getElementById("nav"+i);...

  3. #3
    Join Date
    Jun 2004
    Location
    Northwest Colorado
    Posts
    4,630
    Thanks, nnormal. But i has to start at 0, for elsewhere in the function. I'll try ("nav"+(i++));

  4. #4
    Join Date
    Jun 2004
    Location
    Northwest Colorado
    Posts
    4,630
    Or, I could just rename my ID's nav0-nav2.

    D'oh!

Posting Permissions

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