Forked from AllThingsSmitty/toggle-css-script-on-off.js
Created
November 15, 2015 20:56
-
-
Save mervick/bbb7e6ac6ced85e4be3b 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