“JavaScript Add CSS Arquivo” Respostas de código

Javascript CSS Link Append

document.getElementsByTagName("head")[0].insertAdjacentHTML(
    "beforeend",
    "<link rel=\"stylesheet\" href=\"path/to/style.css\" />");
Mobile Star

JavaScript Add CSS Arquivo

var cssFile = document.createElement('link');
    cssFile.rel = 'stylesheet';
    cssFile.href = "styles.css";  // or path for file {themes('/styles/mobile.css')}
    document.head.appendChild(cssFile); // append css to head element
Healthy Hamster

Link Stylesheet em JavaScript

var cssId = 'myCss';  // you could encode the css path itself to generate id..
if (!document.getElementById(cssId))
{
    var head  = document.getElementsByTagName('head')[0];
    var link  = document.createElement('link');
    link.id   = cssId;
    link.rel  = 'stylesheet';
    link.type = 'text/css';
    link.href = 'http://website.com/css/stylesheet.css';
    link.media = 'all';
    head.appendChild(link);
}
Grotesque Gaur

Anexar o arquivo CSS com JavaScript

var cssFile = document.createElement('link');
    cssLink1.rel = 'stylesheet';
    cssLink1.href = "styles.css";  // or path for file {themes('/styles/mobile.css')}
    document.head.appendChild(cssFile); // append css to head element
Batman

Respostas semelhantes a “JavaScript Add CSS Arquivo”

Perguntas semelhantes a “JavaScript Add CSS Arquivo”

Mais respostas relacionadas para “JavaScript Add CSS Arquivo” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código