Home > Article > Web Front-end > How to remove css styles
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.
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!