原生JS获取元素 margin padding 等值的方法
var getStyleVal =function(el, attr){ var v=0; if(el.currentStyle){ v= el.currentStyle[attr] } else { v= getComputedStyle(el,false)[attr]; } return parseInt(v.replace("px","")) } 参考文章:https://www.w3h5.com/post/145.html
版权属于:Joyber
本文链接:https://blog.qqvbc.com/default/248.html
转载时须注明出处及本声明