
 本文实例讲述了js获取内联样式的方法。分享给大家供大家参考。具体实现方法如下:
 代码如下:
javascript 获取内联样式
//获取内联样式元素
function getStyle( obj , attr )
{
if ( window.getComputedStyle ) {
return getComputedStyle( obj , null )[attr];
}else{
return obj.currentStyle[attr];
}
}
//获取对象
function $(id){
return document.getElementById(id);
}
var box = $('box');
//打印样式
alert(getStyle(box , 'background-position'));
 script>
希望本文所述对大家的javascript程序设计有所帮助。