Home  >  Article  >  Web Front-end  >  How to remove css styles

How to remove css styles

青灯夜游
青灯夜游Original
2021-07-15 16:33:305080browse

You can use jQuery's removeattr() or css() method to delete css styles. Use the "css("property","")" statement to delete a single css style. Use "$(selector).removeAttr ("style")" statement can delete all css styles.

How to remove css styles

The operating environment of this tutorial: windows7 system, CSS3&&HTML5&&jquery version 1.10.0, Dell G3 computer.

You can use jQuery's removeattr() or css() method to delete css styles.

Method 1: Use the css() method

The css() method sets or returns one or more style attributes of the selected element.

Syntax:

css("属性","")

Example:

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

Method 2: Use removeattr()

removeAttr() method to select Remove attributes from the element.

Grammar:

$(selector).removeAttr("style")

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

The above is the detailed content of How to remove css styles. 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
Previous article:Is css case insensitive?Next article:Is css case insensitive?