Javascript manipulates CSS properties

  • 2020-03-30 01:07:58
  • OfStack


var getstyle = function(elementID,attribute){
 obj = document.getElementById(elementID);
//  In the front is IE and in the back is HTML
 return obj.currentStyle ? obj.currentStyle[attribute] : document.defaultView.getComputedStyle(obj, false)[attribute];
}

There is also one that gets the style attribute written in HTML


document.getElementById("elementId").style.paddingLeft;


Related articles: