Home>Article>Web Front-end> How to remove CSS styles with JS/jQuery

How to remove CSS styles with JS/jQuery

醉折花枝作酒筹
醉折花枝作酒筹 Original
2021-04-09 10:04:37 2596browse

Method: 1. Use js, the syntax "document.getElementById("id name").removeAttribute("style")"; 2. Use jQuery, the syntax "$("id name").removeAttr( "style","")".

How to remove CSS styles with JS/jQuery

The operating environment of this tutorial: windows7 system, javascript1.8.5&&jquery2.1.1 version, Dell G3 computer.

Sometimes it is necessary to add and remove CSS styles, such as adding the display attribute and setting it to hidden. Sometimes it is necessary to remove the display attribute.

JS/jQuery Add or remove CSS styles

//通过JS移除css样式 document.getElementById("tab1").removeAttribute("style"); //通过jQuery移除css样式 $("//m.sbmmt.com/m/faq/#tab1").removeAttr("style","");

Example

    信息管理         

张三

微信号:zhangsan

部门:安全部

信息列表

添加信息

[Recommended learning:javascript video tutorial]

The above is the detailed content of How to remove CSS styles with JS/jQuery. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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