本教程操作环境:windows7系统、css3&&html5&&jquery1.10.0版、dell g3电脑。
可以利用jquery的removeattr()或css()方法来删除css样式。
方法1:使用css()方法
css() 方法设置或返回被选元素的一个或多个样式属性。
语法:
css("属性","")
示例:
<script type="text/javascript"> $(function(){ $("li").mouseover(function(){ //添加css样式 $(this).css("background","#ffdd00"); }); $("li").mouseout(function(){ //移出css样式 $(this).css("background",""); }); }); </script>
方法2:使用removeattr()
removeattr() 方法从被选元素中移除属性。
语法:
$(selector).removeattr("style")
更多编程相关知识,请访问:编程视频!!
以上就是如何删除css样式的详细内容。