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

How to cancel style in css

coldplay.xixi
coldplay.xixiOriginal
2021-04-16 16:58:108150browse

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)

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");

Example:

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

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!

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