I have been looking for a nifty style-switching script, and have found none. So here is the code for a checkbox-based style switcher. This uses jQuery.
The Javascript:
-
/*ChangeStyle.js:
-
* -by Skaman Sam Tyler – http://rbe.homeip.net
-
*
-
* This script uses checkboxes to add and remove stylesheets from the page.
-
* It takes the value of the ‘rel’ attribute from the checkbox and creates a stylesheet link with it.
-
* */
-
-
if ($) { //check for jQuery
-
-
//on document load, uncheck all checked boxes and add function handler for
-
$(document).ready( function() {
-
$(‘.styleToggle’).removeAttr("checked"); //uncheck all checked
-
$(‘.styleToggle’).click( function() { //add handler for clicking
-
toggleStyle(this.getAttribute("rel"));
-
return true;
-
});
-
});
-
-
//the toggling of the style. it takes a single parameter: the href of the stylesheet to toggle
-
function toggleStyle(href) {
-
-
//check for presence of link, if it exists, delete it, else, add it.
-
if($(‘link[href*='+href+']‘).size()!=0){
-
$(‘link[href*='+href+']‘).remove();
-
}else{
-
console.log("Adding: "+$(‘link[href*='+href+']‘));
-
$(‘head’).append(‘<link rel="stylesheet" href="’+href+‘" type="text/css" media="screen" />’);
-
}
-
}
-
}
The HTML file should include something like this:
-
<form name="styleSwitchForm">
-
</ul>
-
</form>
-
Tags: css, jQuery, style switcher

Thanks for this looks like it could come in very handy.
Hey…
I don’t mean to change the topic, but where did you people figure out how to program in HTML?…
I learned HTML and JavaScript in late 1996 by reading through simple examples and tweaking them to fit what I needed. There were no free/cheap WYSIWYG editors, so I had to be creative. The general consensus on IRC channels at the time was to go to a page that incorporated a neat feature I wanted to learn, then view the source and tinker with it until I got it to do what I wanted. With the popularity of open source and the plethora of applications available today, you can use this method to learn almost any programming language!