How to remove css attributes in js

WJ
Release: 2020-05-30 16:47:44
Original
3727 people have browsed it

How to remove css attributes in js

#How to remove css attributes in js?

At work, I often need to use Javascript to change the style of page elements. One way is to change the CSS class (Class) of the page element. In traditional Javascript, we usually do this by processing the classname attribute of HTML Dom. We can also remove css styles through this method.

JavaScript method to remove css attributes:

Use document.getElementById("objid").className="" to clear the style;

className attribute sets or returns the class attribute of the element. You can change the css style more by changing the class attribute.

In some browsers (such as Chrome), whatever value you assign to it will be returned. In IE, it is more painful. It will format the output, capitalize attributes, change the order of attributes, and remove the last semicolon

Example:

   信息管理        
Copy after login

Related recommendations:JS tutorial

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

Related labels:
js
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!