“Dołącz plik CSS z JavaScript” Kod odpowiedzi

JavaScript CSS Link Dodatek

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

JavaScript Dodaj plik CSS

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

Dołącz plik CSS z 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

Odpowiedzi podobne do “Dołącz plik CSS z JavaScript”

Pytania podobne do “Dołącz plik CSS z JavaScript”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu