Home > Web Front-end > Front-end Q&A > how to remove css

how to remove css

藏色散人
Release: 2021-04-26 09:47:35
Original
3099 people have browsed it

How to delete css: first create a new html file; then use the p tag to create a line of text, and set the class attribute of the p tag to one; then use css to set the text size to 20px and the text color to red; Finally, execute the myfun() function to delete the css style.

how to remove css

The operating environment of this article: windows7 system, css3&&javascript version 1.8.5, Dell G3 computer.

Create a new html file, named test.html, to explain how to use js to delete css styles.

how to remove css

In the test.html file, use the p tag to create a line of text, and set the class attribute of the p tag to one and the id attribute to pp.

how to remove css

In the test.html file, through the class attribute of the p tag, use css to set the text size to 20px and the text color to red. At the same time, define another style with the class name two and set the text to 20px.

how to remove css

In the test.html file, use the button tag to create a button with the button name "Delete css".

how to remove css

Bind the onclick event to the button. When the button is clicked, execute the myfun() function.

how to remove css

In the test.html file, in the js tag, create the myfun function. Within the function, use the getElementById() method to obtain the p element object through the id of the p tag. , and then set the class attribute of the p tag to the new attribute name two through the setAttribute() method, thereby deleting the original style and setting a new style at the same time to remove the color css style of the p tag.

how to remove css

Open the test.html file in the browser, click the button to see the effect.

how to remove css

[Recommended learning: css video tutorial]

The above is the detailed content of how to remove css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
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