I want to select an element which was created by the CSS selector :before.
I tried it by using $('#element:before'), but that did not work, because it selected the whole element and not only the :before element.
Here is the sample code: DEMO
In that example, only the string “1. ” should be red, not the whole string. Any idea how to do this?
JQuery cannot set css properties on :before content, since it is not contained in an element. If you want to be able to manipulate the color of the :before content with javascript, you can create an extra css class, and add/remove this class.
example