Jump to content

Getting Styles


shadowayex

Recommended Posts

Well, I tried all kinds of different things with no avail with any of them.I just want to get styles from a certain element.var x = document.getElementById(id).style.width;That does not work, evidently, but I want something that would do what that would seem to do if it worked.I read on getComputedStyle, currentStyle, and getpropertyValue and can't get any of them to work, although I can't find any prototypes or good references to go off of.Anybody got a good solution?

Link to comment
Share on other sites

If a width wasn't assigned to the style, it won't be there. You can use the offsetWidth property to obtain the width of any element.

Link to comment
Share on other sites

If a width wasn't assigned to the style, it won't be there. You can use the offsetWidth property to obtain the width of any element.
Well I know that. That was just an example, I mean like padding or margin for instance.
Link to comment
Share on other sites

I think you cannot directly access style values in javascript unless they were set by javascript. You might want to look at the stylesheet object and read the values stored in there. There are cross-browser issues.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...