Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Although they are rendered by browsers through CSS as if they were like other real DOM elements, pseudo-elements themselves are not part of the DOM, because pseudo-elements, as the name implies, are not real elements, and therefore you can't select and manipulate them directly with jQuery (or <em>any</em> JavaScript APIs for that matter, not even the <a href="http://www.w3.org/TR/selectors-api" rel="nofollow noreferrer">Selectors API</a>). This applies to any pseudo-elements whose styles you're trying to modify with a script, and not just <code>::before</code> and <code>::after</code>.</p> <p>You can only access pseudo-element styles directly at runtime via the CSSOM (think <code>window.getComputedStyle()</code>), which is not exposed by jQuery beyond <code>.css()</code>, a method that doesn't support pseudo-elements either.</p> <p>You can always find other ways around it, though, for example:</p> <ul> <li><p>Applying the styles to the pseudo-elements of one or more arbitrary classes, then toggling between classes (see <a href="https://stackoverflow.com/questions/5041494/manipulating-css-pseudo-elements-using-jquery-e-g-before-and-after/5335771#5335771">seucolega's answer</a> for a quick example) — this is the idiomatic way as it makes use of simple selectors (which pseudo-elements are not) to distinguish between elements and element states, the way they're intended to be used</p></li> <li><p>Manipulating the styles being applied to said pseudo-elements, by altering the document stylesheet, which is much more of a hack</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload