How can i print the value of style attribute of an html element using javascript. I can get a specific style property value using document.getElementById('myId').style.property, where property is something like width, height etc.
However, how can I get the entire list of styles for an element?
document.getElementById('myId').style.cssTextas a String, ordocument.getElementById('myId').styleas an Object.Edit:
As far as I can tell, this returns the “actual”, inline style. On the element
<a id='myId' style='font-size:inherit;'>,document.getElementById('myId').style.cssTextshould return"font-size:inherit;". If that is not what you want, trydocument.defaultView.getComputedStyleordocument.getElementById('myId').currentStyle(the first one is all except IE, the second one is IE only). See here for more on computed vs. cascaded styles.