?
Path : /home/admin/public_html/old/happyezystyle/ |
Current File : /home/admin/public_html/old/happyezystyle/zebraStripe.js |
/*********************************************************************** # Project: zebraStripe CSS tables # Language: JavaScript/CSS/HTML # Author: Copyright: Denny Schlesinger # Date: January 7, 2012 # Warrantee: NONE whatsoever but enjoy it all the same # Notice: If you use this code, please include this copyright notice /**********************************************************************/ function zebraStripe(table) { // set variables var list, light, dark, even, count, elem, clas; light = 'row backgroundLight'; dark = 'row backgroundDark'; even = true; // get table's div nodes list = document.getElementById(table).getElementsByTagName('div'); // loop through css table count = list.length; for(i = 0; i < count; i++) { // get ith element from the node list elem = list[i]; // get the element's class attribute (can't use 'class' a reserved word) clas = elem.getAttribute('class'); // if element's class is row, process, else ignore if(clas.slice(0,3) == 'row') { // if even, light, else, dark elem.setAttribute("class", even ? light : dark); // toggle even/odd (true/false) even = ! even; } } }