1

As far as I concern, .style.some_property only returns the value of the property if I setting it in javascript. If I don't, it returns empty string. So, is there any other way other than jQuery methods like css() and prop() to get value of a css property?

KTDPMH
  • 31
  • 5
  • CSS properties defined by style sheets and CSS properties applied by JavaScript are *very* different – user229044 Jan 27 '15 at 22:07
  • so how jQuery can allow us to get css properties? – KTDPMH Jan 27 '15 at 22:07
  • [`window.getComputedStyle`](https://developer.mozilla.org/en-US/docs/Web/API/window.getComputedStyle) – Felix Kling Jan 27 '15 at 22:08
  • By value of CSS property do you mean the actual styling like padding: 10px? – mattfetz Jan 27 '15 at 22:08
  • [How to retrieve a style's value in javascript?](http://stackoverflow.com/questions/2664045/how-to-retrieve-a-styles-value-in-javascript) – Jonathan Lonowski Jan 27 '15 at 22:09
  • This is also explained in the [jQuery documentation about `.css`](http://api.jquery.com/css/): *"The `.css()` method is a convenient way to get a style property from the first matched element, especially in light of the different ways browsers access most of those properties (the `getComputedStyle()` method in standards-based browsers versus the `currentStyle` and `runtimeStyle` properties in Internet Explorer) and the different terms browsers use for certain properties"* – Felix Kling Jan 27 '15 at 22:10
  • [getComputedStyle](https://developer.mozilla.org/en-US/docs/Web/API/window.getComputedStyle) This will return all applied styles to an element – bmartin Jan 27 '15 at 22:11

0 Answers0