css取消樣式的方法:1、移除全部樣式使用【removeattr(“style”)】;2、移除單個(gè)樣式使用【css(“屬性”,“”)】。
本教程操作環(huán)境:windows7系統(tǒng)、css3版,DELL G3電腦。
css取消樣式的方法:
1、移除全部樣式使用removeattr(“style”);
removeAttr() 方法從被選元素中移除屬性。
語法:
$(selector).removeAttr(attribute)
2、移除單個(gè)樣式使用css(“屬性”,“”);
css() 方法設(shè)置或返回被選元素的一個(gè)或多個(gè)樣式屬性。
如需設(shè)置指定的 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>
相關(guān)教程推薦:CSS視頻教程