标签:style blog http color io ar java sp div
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html> 3 <head> 4 <meta charset="UTF-8" /> 5 <!--meta http-equiv="x-ua-compatible"content="ie=7"/--> 6 <title>css</title> 7 <style type="text/css"> 8 #div0{ 9 width:100px; 10 height:100px; 11 background:red; 12 } 13 </style> 14 15 <script type="text/javascript"> 16 window.onload = function(){ 17 var oDiv = document.getElementById("div0"); 18 19 var sheet = document.styleSheets[0]; 20 var ruls = sheet.cssRules || sheet.rules; 21 var rule = ruls[0]; 22 alert(rule.selectorText); 23 alert(rule.style.cssText); 24 alert(rule.style.background); 25 26 if(document.all) 27 { 28 sheet.addRule("#div0","color:blue",0); 29 }else 30 { 31 sheet.insertRule("#div0{color:orange}",0) 32 } 33 34 35 } 36 </script> 37 </head> 38 <body> 39 <div id="div0">DIV</div> 40 </body> 41 </html>
标签:style blog http color io ar java sp div
原文地址:http://www.cnblogs.com/tuoyuan/p/4025894.html