获取CSS样式

 行内样式:

document.getElementById("id").style.property="值"


非行内样式:
function(obj,attr){
  if(obj.currentStyle){
  return obj.currentStyle[attr]
  }
  else{
   return getComputedStyle(obj,false)[attr]
  } 
}

具体attr参考可http://www.w3school.com.cn/jsref/dom_obj_style.asp 

posted on 2017-03-12 20:51  周裕涛  阅读(188)  评论(0编辑  收藏  举报

导航