Forked from AllThingsSmitty/toggle-css-script-on-off.js
Created
January 24, 2016 08:35
-
-
Save nucliweb/69239992b88947ca142e to your computer and use it in GitHub Desktop.
Disable/enable a stylesheet or script
This file contains hidden or 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
// 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