Skip to content

Instantly share code, notes, and snippets.

@wpgaurav
Created September 24, 2021 05:51
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 wpgaurav/438e446c585e03d5fd5adb8f8f452779 to your computer and use it in GitHub Desktop.
Save wpgaurav/438e446c585e03d5fd5adb8f8f452779 to your computer and use it in GitHub Desktop.
Load CSS on Button Click - Useful for DarkMode config
<link id="custom_stylesheet" rel="stylesheet" type="text/css" href="" />
<script>
function LoadStyleAndScript()
{
$("#custom_stylesheet").attr("href", "//example.com/mystyle.css");
}
</script>
<input type="button" onClick="LoadStyleAndScript();" value="Load it">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment