topical media & game development

talk show tell print

#javascript-css-style-switch-script.js / js



  function switchStyle(){
    // return array of all DIV elements
    var divs = document.getElementsByTagName("DIV");
    // Iterate through all DIVs in array
    for(var i = 0; i < divs.length; i++){
      // If current DIV is using "textDefault" styling,
      // change it to use "textAlternate" styling
      if(divs[i].className == "textDefault")
        divs[i].className = "textAlternate";
      // If current DIV is using "textAlternate" styling,
      // change it back to use "textDefault" styling
      else if(divs[i].className == "textAlternate")
        divs[i].className = "textDefault";
    }
  }
  
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.