I want to swap the CSS stylesheet file without reloading the page. I'm wondering how to cycle through an array of multiple stylesheets by clicking a single source (div, #button), returning to the default, and then continuously looping through the list. It would also be great if the browser could remember what stylesheet the website is currently on for page to page continuity, though this is not necessary. The following is what I have so far...
HTML:
<link id="pagestyle" rel="stylesheet" type="text/css" href="default.css">
<div id="button" style="width: 100px; height: 100px; background-color: red;"></div>
Javascript:
var stylesheets = [
"style1.css",
"style2.css",
"style3.css",
"default.css"
];
function swapStyleSheet(sheet){
document.getElementById('pagestyle').setAttribute('href', sheet);
}