日期:2014-05-16  浏览次数:20298 次

js样式相关
大多数情况下,我们都会很自然的使用node.style.xx的方式获得样式,但这种方法只适用于内置在标签里的style。如果要获得<style type="text/css"></style>,或者.css文件里的样式,方法有两种,一种是通过document.styleSheets对象,另一种是通过“最终样式”对象,其中 IE中这个对象叫做currentStyle,FF中这个对象叫做document.defaultView。

读样式:
if(document.all){
	eval("node.currentStyle." + styleName);
} else {
	eval("document.defaultView.getComputedStyle(node, null)." + styleName);
}


写样式:
还是要用node.style.styleName = value的方式