星空网 > 软件开发 > 网页设计

JS获取非行间样式及兼容问题

获取非行间样式:

<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <title>获取非行间样式</title>  <style>    #div1{height: 200px;width: 200px;background-color: red;}  </style>  <script>    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'));    }  </script></head><body><div id="div1"></div></body></html>

 




原标题:JS获取非行间样式及兼容问题

关键词:JS

JS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

春节假期运营:https://www.goluckyvip.com/tag/7143.html
刷单服务商:https://www.goluckyvip.com/tag/7147.html
赶跟卖服务商:https://www.goluckyvip.com/tag/7148.html
新产品销售权:https://www.goluckyvip.com/tag/7149.html
中国制:https://www.goluckyvip.com/tag/715.html
电商补贴:https://www.goluckyvip.com/tag/7150.html
中国有哪些著名的酒店品牌。:https://www.vstour.cn/a/411242.html
石象湖景区门票-石象湖景区门票优惠政策:https://www.vstour.cn/a/411243.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流