I'm trying to make a page where you can change a page's layout through 2 separate CSS's via a button. i want to button to change text when it toggles the layouts as well. i have no clue how to do this with an entire CSS file, but here is something i made to change the background. could i use this logic to change the CSS of a page? HTML <in <input type="button" value="change layout" onclick="toggle()" /> Code (markup): JavaScript var flag = 0; function toggle(){ if(flag==0){ document.getElementById("container").style.backgroundImage="blah.jpg"; flag=1; } else if(flag==1){ document.getElementById("container").style.backgroundImage="blah2.jpg"; flag=0; } } Code (markup):
html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>XHTML-document</title> <link rel="stylesheet" type="text/css" id="stylesheet" href="blah.css" /> <script type="text/javascript"> var flag = 0; function toggle(){ if(flag==0){ document.getElementById("stylesheet").href="blah2.css"; flag=1; document.getElementById("switch").value="switch to blah.css"; }else if(flag==1){ document.getElementById("stylesheet").href="blah.css"; flag=0; document.getElementById("switch").value="switch to blah2.css"; } } </script> </head> <body> <div id="container"> <input id="switch" type="button" value="change layout" onclick="toggle()" /> </div> </body> </html> Code (markup): blah.css #container {background-image: url(blah.jpg);} Code (markup): blah2.css #container {background-image: url(blah2.jpg);} Code (markup):