Skip to content

Instantly share code, notes, and snippets.

@brh55
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brh55/5629850a14ded5a35453 to your computer and use it in GitHub Desktop.
Save brh55/5629850a14ded5a35453 to your computer and use it in GitHub Desktop.
Client-Side Stylesheet Replacer with jQuery--Simple, not efficient, but works.
<select name="theme-menu" id="themes" >
<option value="override">Default Theme</option>
<option value="penn-theme">Penn Theme</option>
<option value="neutral-theme">Neutral Theme</option>
</select>
$( document ).ready(function() {
var theme;
function setTheme(theme){
switch (theme) {
case "override":
$('link[rel=stylesheet][href$="penntheme.css"]').remove();
$('link[rel=stylesheet][href$="neutral-theme.css"]').remove();
$('head').append('<link rel="stylesheet" href="assets/design/css/' + theme + '.css" type="text/css" />');
break;
case "penn":
$('link[rel=stylesheet][href$="override.css"]').remove();
$('link[rel=stylesheet][href$="neutral-theme.css"]').remove();
$('head').append('<link rel="stylesheet" href="assets/design/css/' + theme + '.css" type="text/css" />');
break;
case "neutral":
$('link[rel=stylesheet][href$="override.css"]').remove();
$('link[rel=stylesheet][href$="neutral-theme.css"]').remove();
$('head').append('<link rel="stylesheet" href="assets/design/css/' + theme + '.css" type="text/css" />');
break;
}
}
$('select[name="theme-menu"]').change(function() {
theme = $('#themes').val();
setTheme(theme);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment