Created
July 7, 2012 16:01
-
-
Save ekstinehickorysnippets/3067002 to your computer and use it in GitHub Desktop.
Javascript: Stylesheet Switcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link id="linkidstylesheet" href='default.css' rel='stylesheet' type='text/css' > | |
<script type="text/javascript" src="http://www.google.com/jsapi"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a class="colorbox btnstylesheet1" href="?theme=sty1" title="style 1"></a> | |
<a class="colorbox btnstylesheet2" href="?theme=sty2" title="style 2"></a> | |
<a class="colorbox btnstylesheet3" href="?theme=sty3" title="style 3"></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove if not in html | |
<script> | |
google.load("jquery", "1.3.1"); | |
google.setOnLoadCallback(function() | |
{ | |
// Apply some CSS3 to keep the CSS file CSS 2.1 valid | |
$("h1").css("text-shadow", "0px 2px 6px #000"); | |
$("h2 a").css("text-shadow", "0px 2px 6px #000"); | |
// Color changer | |
$(".btnstylesheet1").click(function(){ | |
$("#linkidstylesheet").attr("href", "stylesheet1.css"); | |
return false; | |
}); | |
$(".btnstylesheet2").click(function(){ | |
$("#linkidstylesheet").attr("href", "stylesheet2.css"); | |
return false; | |
}); | |
$(".btnstylesheet3").click(function(){ | |
$("#linkidstylesheet").attr("href", "stylesheet3.css"); | |
return false; | |
}); | |
}); | |
// Remove if not in html | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment