好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

JS获取非行间样式及兼容问题-Web学海无涯

获取非行间样式:

 
 "  en  " >
 
     "  UTF-8  " >
     获取非行间样式 
      
        #div1{height: 200px;width: 200px;background - color: red;}
      
      
        function getStyle(obj,name){
              if  (obj.currentStyle){
                  return   obj.currentStyle[name]; //IE浏览器
            }
              else   if  (getComputedStyle){      //Firefox,chrome浏览器
                  return  getComputedStyle(obj, null  )[name];
            }
        }
        window.onload  =  function(){
              var  oDiv = document.getElementById( '  div1  '  );
            alert(getStyle(oDiv,  '  height  '  ));
        }

      
 
 

查看更多关于JS获取非行间样式及兼容问题-Web学海无涯的详细内容...

  阅读:31次