看板 Web_Design 關於我們 聯絡資訊
javasctipr要怎麼讀到某個物件的class裡面的style? 假設有個東西長這樣: <style> .foo {background: red;} </style> <div class="foo" style="margin: 0 0 0 0;">.</div> 然後有一段code var obj = 上面那個div物件 alert(String(obj.style.margin)); // 這行可以 alert(String(obj.style.background)); // 讀不到 要怎麼改? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.228.190.227
holio:試試看 getComputedStyle 11/04 10:42
bennylu:#2757 11/04 11:48
Numino:background-color instead of background 11/04 13:45
bennylu:誰說background一定要是background-color? 11/04 20:40
bennylu:background:url(bg.gif) red 怎麼說? 11/04 20:41
Fenikso:解決了 謝謝^^ 11/08 16:30