css取消樣式的方法:1、移除全部樣式使用【removeattr(“style”)】;2、移除單個樣式使用【css(“屬性”,“”)】。
本教程操作環境:windows7系統、css3版,DELL G3電腦。
css取消樣式的方法:
1、移除全部樣式使用removeattr(“style”);
removeAttr() 方法從被選元素中移除屬性。
語法:
$(selector).removeAttr(attribute)
2、移除單個樣式使用css(“屬性”,“”);
css() 方法設置或返回被選元素的一個或多個樣式屬性。
如需設置指定的 CSS 屬性,請使用如下語法:
css("propertyname","value");
示例:
<script type="text/javascript"> $(function(){ $("li").mouseover(function(){ //添加css樣式 $(this).css("background","#ffdd00"); }); $("li").mouseout(function(){ //移出css樣式 $(this).css("background",""); }); }); </script>
相關教程推薦:CSS視頻教程