Home > Web Front-end > CSS Tutorial > How to cancel style in css

How to cancel style in css

coldplay.xixi
Release: 2023-01-05 16:09:27
Original
8231 people have browsed it

How to cancel styles in css: 1. To remove all styles, use [removeattr ("style")]; 2. To remove a single style, use [css ("attribute", "")].

How to cancel style in css

The operating environment of this tutorial: windows7 system, css3 version, DELL G3 computer.

How to cancel styles in css:

1. To remove all styles, use removeattr("style");

The removeAttr() method removes attributes from selected elements.

Syntax:

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

2. To remove a single style, use css ("property", "");

css() method setting or Returns one or more style properties of the selected element.

To set specific CSS properties, please use the following syntax:

css("propertyname","value");
Copy after login

Example:

 <script type="text/javascript">
    $(function(){
$("li").mouseover(function(){
//添加css样式
$(this).css("background","#ffdd00");
});
$("li").mouseout(function(){
//移出css样式
$(this).css("background","");
});
   
    });
    </script>
Copy after login

Recommended related tutorials: CSS video tutorial

The above is the detailed content of How to cancel style in css. 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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template