nucliweb
1/24/2016 - 8:35 AM

Disable/enable a stylesheet or script

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