shadowayex Posted May 24, 2009 Share Posted May 24, 2009 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 More sharing options...
Ingolme Posted May 24, 2009 Share Posted May 24, 2009 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 More sharing options...
shadowayex Posted May 24, 2009 Author Share Posted May 24, 2009 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 More sharing options...
jeffman Posted May 24, 2009 Share Posted May 24, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.