0

I need help how to check in a if condition for a ::after or ::before inside a selected part of code. To manipulate a CSS attribute if it exists. For example:

if (::after || ::before == exists) {
  // do something
}

don´t call it a duplicate, its not. please read carefully

Deniz
  • 1,435
  • 14
  • 29
  • The only way to do this would be to use `getComputedStyle()` to retrieve a CSS setting from the `:before`/`:after` rule. It's not a very pretty solution, and certainly shouldn't be used in a production environment. What goal are you actually trying to achieve, as this sounds like an X/Y problem. – Rory McCrossan Feb 02 '18 at 15:23
  • @DanielAWhite I don't believe that's a duplicate, as it's about amending the pseudo rules themselves, not about checking if any are applied to the element. – Rory McCrossan Feb 02 '18 at 15:24
  • Check for an ::after or ::before where exactly? Anywhere in the document? A specific element? Does this if condition operate in the context of said element? Do you want to check for the presence of an ::after/::before CSS rule, or do you just want to check if a pseudo-element is being generated? Whose CSS property are you trying to manipulate, the pseudo-element's, or some other element's? It's a bit hard to carefully read something that's barely coherent. – BoltClock Feb 02 '18 at 16:19

0 Answers0