Skip to content

Instantly share code, notes, and snippets.

@AllThingsSmitty
Created November 15, 2015 19:39
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save AllThingsSmitty/52685683a2eab084d7af to your computer and use it in GitHub Desktop.
Save AllThingsSmitty/52685683a2eab084d7af to your computer and use it in GitHub Desktop.
Disable/enable a stylesheet or script
// Use the Boolean `disabled` attribute
myCSS.disabled = true;
myJS.disabled = true;
// Create a stylesheet toggle button:
var stylesheet = document.getElementById('boot'),
btn = document.querySelector('.btn');
btn.addEventListener('click', function () {
stylesheet.disabled = (stylesheet.disabled === false) ? true : false;
}, false);
// Demo by Louis Lazaris: https://jsbin.com/jeveze/edit?html,js,output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment