How to remove css style in jquery?

青灯夜游
Release: 2020-11-20 16:50:56
Original
14624 people have browsed it

Jquery method to remove css style: 1. Use the attr() or css() method to set the css attribute value to empty to remove a single css style; 2. Use the removeAttr() method to remove it from the selected element Remove attributes; 3. Use the removeClass() method to remove attributes from the selected element.

How to remove css style in jquery?

Related recommendations: "jQuery Video Tutorial"

jquery remove css style

1. Use the attr() method or css() to remove a single css style

attr() method can set the attributes and values of the selected element , you can set one or more attribute/value pairs for the matching element.

If you want to use attr() to remove css style, you can set the attribute value to empty.

Example:

$("#show").attr("style","");
Copy after login

css() method can set one or more style attributes of the selected element.

If you want to use css() to remove css style, you can set the attribute value to empty.

Example:

$("#show").css("style","");
Copy after login

2. Use the removeAttr() method to remove css styles

removeAttr() method removes one or more elements from the selected element attributes.

Grammar

$(selector).removeAttr(attribute)
Copy after login

Example:

$("#tab1").removeAttr("style","");
Copy after login

3. Use removeClass() method to remove css style

removeClass() method from Removes one or more classes from the selected elements.

Note: If no parameters are specified, this method will remove all classes from the selected elements.

Example: Remove the "intro" class from all

elements:

       

这是一个标题

这是一个段落。

这是另一个段落。

Copy after login

For more programming-related knowledge, please visit:Programming Video Course! !

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

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 Recommendations
Popular Tutorials
More>
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!