Home > Web Front-end > JS Tutorial > body text

How to dynamically load style sheets with JavaScript_javascript tips

WBOY
Release: 2016-05-16 16:08:06
Original
836 people have browsed it

The example in this article describes the method of dynamically loading style sheets in JavaScript. Share it with everyone for your reference. The details are as follows:

If we need to change the skin, we can dynamically load the skin's style sheet through JS code. The following code can do it. It is very simple. You only need to make this code into a function and call it dynamically.

var el = document.createElement('link');
el.rel = 'stylesheet';
el.type = 'text/css';
el.href = 'http://www.jb51.net/...' + 'styles.css';
document.body.appendChild(el);
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template