//創建
var sheet=document.createElement('style');
document.bodt.appendChild(sheet);
sheet.styleSheet.cssText="div{border:2px solid black; background-color:blue;}";
//刪除
var beRemoved=document.getElementById('styleSheetId');
var sheetParent=beRemoved.parentNode;//獲取要刪除樣式的父類
sheetParent.removeChild(beRemoved);//用removeChild()從父類中刪除樣式
//用title區分內部和外部樣式表
function getStyleSheet(unique_title){
for(var i=0;i<document.styleSheets.length;i++){
var sheet=document.styleSheets[i];
if(sheet.title==unique_title){
return sheet;
}
}
}
//通過disabled屬性禁用CSS
function disableSheet(){
document.getElementById('disable_example').disabled=true;
}
function enableSheet(){
document.getElementById('disable_example').disabled=false;
}