Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mervick/bbb7e6ac6ced85e4be3b to your computer and use it in GitHub Desktop.
Save mervick/bbb7e6ac6ced85e4be3b 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