js中获取元素的样式兼容性的写法

1:设计元素的样式:el.style.color="red"||el.style["color"]="red"
  获取元素的样式:el.style.color||el.style["color"](只能获取直接样式的

值)
  获取内部样式或外部样式的值:

      function getStyle(ele,style){
        return ele.currentStyle?obj.currentStyle

[style]:window.getComputedStyle(ele)[style];
            };

posted on 2017-03-09 17:57  熊熊之火  阅读(453)  评论(0编辑  收藏  举报

导航