Home >
Web Front-end >
JS Tutorial >
js implements two sets of css switching codes for a single html page_javascript skills
js implements two sets of css switching codes for a single html page_javascript skills
WBOY
Release: 2016-05-16 17:37:16
Original
1312 people have browsed it
Today I studied the effect of using the setAttribute method of JS to implement two style sheets on one page. The specific method is as follows: Step 1: Define an id in the element connecting the style sheet, such as
The code of this function can be placed anywhere on the page. Step 3: Add a function trigger event for the connection to change the style sheet of the page. The code is as follows:
This effect has been tested under both IE and FF. I believe everyone will understand it after reading it. Using this method we You can let the viewer choose the style sheet that needs to be displayed. For example, the elderly can choose a style sheet with a larger font. Two points to note here are: In this example, the name after the function name cannot be links or link. If it is links or link, the style sheet will not be changed. I don’t know the specific reason. Maybe It is a reserved character of JavaScript. In addition, if you want to change the style of the entire page, you need to define the body height as 100% in the style sheet file
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