You can't.
1) The selector, p:before
, is not just a selector -- the psuedo element defines functionality that does not affect the actual selection. What is jQuery supposed to return, all p
tags? That's all $(...)
does -- it returns a bunch of elements that match your selector. jQuery (Sizzle/querySelectorAll
) doesn't know how to fetch :before
...
2) Psuedo-element/class behaviour is not available via JS APIs either.
The only way to do something like this, dynamically via JS, would be to create a <style>
element, like so:
$('<style>p:before{content:"intro";}</style>').appendTo('head');
May I ask why you want to do this in the first place?