Cómo css de carga / descarga dinámicamente

user3792705:

Yo sé cómo cargar CSS.

injectCss(styles) {
  let styleSheet = document.createElement("style");
  styleSheet.type = 'text/css';
  styleSheet.innerText = styles;
  document.head.appendChild(styleSheet);
}

Cómo descargarlo?

vadivel a:

Espero que esto te ayude.

function injectCss(styles) {
  let styleSheet = document.createElement("style");
  styleSheet.type = 'text/css';
styleSheet.setAttribute("id", "dunamicstylesheet");
  styleSheet.innerText = styles;
  document.head.appendChild(styleSheet);
}

//Create-styleSheet
injectCss('dynamic.css');

//remove-styleSheet
var stylesheet = document.getElementById('dunamicstylesheet');
stylesheet.parentNode.removeChild(stylesheet);

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=281449&siteId=1
Recomendado
Clasificación