1

I have a small question concerning css styles and javascript / jquery. Lets say i define the following css style.

.myStile { padding: 5px }

Now I'd like to access the property of padding while not writing an html element to the document. I came up with the following idea which only works with Firefox (IE and Chrome say NaN)

var div = $('<div class="myStile />');
var padding = parseInt(div.css('padding-left'), 10);

is there a way to make this work in IE and Chrome (well trident and webkit I guess) as well? I know that one's able to read whole css files via javascript (and get the class, the properties and so on ...), but that seems to be a bit overkill.

Dänu
  • 5,791
  • 9
  • 43
  • 56
  • hallo dänu! here is a question i asked a while ago. I think you can get your answers there! http://stackoverflow.com/questions/1285033/read-hover-pseudo-class-with-javascript – meo Jun 08 '10 at 10:16

1 Answers1

0

Thanks meo for your comment. This post answers the question. Here's a google find which answers the "other browsers than chrome, firefox, safari" issue.

Community
  • 1
  • 1
Dänu
  • 5,791
  • 9
  • 43
  • 56