0

Is it possible to read style definition with jQuery/Javascript? In case there are no elements with this style?

Dims
  • 47,675
  • 117
  • 331
  • 600
  • You mean: select elements that not have a style property defined? – David Rodrigues Dec 24 '11 at 19:23
  • Style definition? You mean CSS rule? Within a style sheet? – Šime Vidas Dec 24 '11 at 19:24
  • jQuery can set styles directly onto an object. Or, it can change/add a class to an object to cause it to inherit different CSS rules. I'm quite sure your problem can be solved without putting data in multiple places, but you'd have to describe the details of your problem in order for people to help. – jfriend00 Dec 24 '11 at 19:45

2 Answers2

1

I highly doubt this is possible. Unless you just parse the css file with javascript. What are you actually trying to achieve, and why?

Derk Arts
  • 3,432
  • 2
  • 18
  • 36
  • I want to have a place where some constraints of my page stored. For example, the size of some widget. I found that jQuery is unable to change CSS rules, so I was wondering if reverse is possible. Since it is not, I am forced to put in into 2 places. – Dims Dec 24 '11 at 19:39
  • And you can't just put it in a separate JS file? Would be almost the same as a CSS file, but then it would actually work. :) – Derk Arts Dec 24 '11 at 19:46
0

You can read CSS rules with javascript. The code must be different in IE vs. other browsers, but it is possible.

Some references:

Community
  • 1
  • 1
jfriend00
  • 683,504
  • 96
  • 985
  • 979