Results 1 to 3 of 3

Thread: Zebra: (un)ordered lists

  1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    18
    Vote Rating
    0
      0  

    Default Zebra: (un)ordered lists

    There is code for making zebra tables, but is there zebra lists?

    <pre><code>
    function zebraList(id){
    var even = false;
    var evenColor = arguments[1] ? arguments[1] : "#FFFFFF";
    var oddColor = arguments[2] ? arguments[2] : "#DDD";
    // obtain a reference to the desired list
    // if no such list exists, abort
    var ul = document.getElementById(id);
    if (! ul) { return; }
    var lis = ul.getElementsByTagName("li");
    // and iterate through them...
    for (var h = 0; h < lis.length; h++) {
    var list = lis[h];
    list.style.backgroundColor = even ? evenColor : oddColor;
    // flip from odd to even, or vice-versa
    even = ! even;
    }
    }

    </code></pre>

  2. #2
    Ext User
    Join Date
    Mar 2007
    Posts
    18
    Vote Rating
    0
      0  

    Default

    Oh duh. There is zebra color in the grid control. Nevermind.

  3. #3
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    6,956
    Vote Rating
    20
      0  

    Default

    You could do soemthing like this:

    getEls("ul li:nth-child(odd)").addClass('odd');

Posting Permissions

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