如何使用选择器获取元素的值

Dan*_*nny 0 css jquery pseudo-element

例:

$(document).ready(function(){    

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

});
Run Code Online (Sandbox Code Playgroud)

警报null(我知道价值null当然不是).

Ale*_*tie 5

不幸的是,CCS伪元素(比如:before,:after)不是DOM的一部分(尽管它们被渲染得像它们一样) - 因此它们不能用jQuery来操作.

请参阅:使用jQuery选择和操作CSS伪元素,例如:: before和:: after