获取内联和链接中的样式
生活随笔
收集整理的這篇文章主要介紹了
获取内联和链接中的样式
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
var head = document.getElementById( "box" );// alert( head.style.background )// alert( head.style.cssFloat || head.style.styleFloat ) // 獲取float不一樣// head.style.fontSize = "30px"head.style.color = "#f00";// (typeof head.style.cssFloat != "undefined" ) ? head.style.cssFloat = "right" : head.style.styleFloat = "right" 跨瀏覽器設(shè)置float// var style = ( window.getComputedStyle ? window.getComputedStyle( head,null ) : null ) || head.currentStyle; 跨瀏覽器獲取計(jì)算之后的樣式// alert( style.fontSize )// 這樣可以獲取到內(nèi)聯(lián)和鏈接// 因?yàn)橛?jì)算之后的樣式會(huì)駐留在瀏覽器的計(jì)算樣式里面 所以就可以獲取得到
總結(jié)
以上是生活随笔為你收集整理的获取内联和链接中的样式的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: CA自签证书的颁发及应用
- 下一篇: sizeof 计算struct大小