看板 Web_Design 關於我們 聯絡資訊
我用javascript動態建立CSS, 建立的CSS有發揮作用, 但想alert有多少cssRules,結果是0, 請問各位大大,有人知道為什麼嗎? 以下是程式碼: window.onload = function() { var newStyle=document.createElement('link'); newStyle.setAttribute('type', 'text/css'); newStyle.setAttribute('rel', 'StyleSheet'); newStyle.setAttribute('href', CSS file的路徑); document.getElementsByTagName('head')[0].appendChild(newStyle); alert(document.styleSheets[0].cssRules.length); } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.138.32.63