0

Example:

$(document).ready(function(){    

   height = $('#container-bottom:before').height();
   alert(height);

});

Alerts null (and I know the value is not null of course).

animuson
  • 53,861
  • 28
  • 137
  • 147
Danny
  • 986
  • 1
  • 18
  • 42
  • Can we have a jsfiddle including some example html? In theory $.height should return a unit-less value of the height of the specified element. – Drav Sloan Nov 22 '11 at 02:47
  • @DravSloan Here's a link with the example http://jsfiddle.net/EFXMf/ – Danny Nov 22 '11 at 02:50
  • There aren't any html elements before ... – Kamil Sindi Nov 22 '11 at 02:55
  • Is there any reason for the css selector :before? Removing that from both the css and the jquery select seems to render the same output and give the expected value (200) – Drav Sloan Nov 22 '11 at 02:56

1 Answers1

5

Unfortuantely CCS pseudo-elements (like :before, :after) are not part of the DOM (although they're rendered as if they were) - thus they can't be manipulated with jQuery.

See: Selecting and manipulating CSS pseudo-elements such as ::before and ::after using jQuery

Community
  • 1
  • 1
Alex Peattie
  • 26,633
  • 5
  • 50
  • 52
  • Thanks, well, after all I had to use a real element and that fixed the problem, instead of the pseudo element :before. – Danny Nov 22 '11 at 03:03