Quite often I run into situations where I need to modify the CSS styles of the pseudo elements dynamically. This post shows you different ways in which it can be done!
Sample markup and styles to start with,
To modify the color of the pseudo element -
or jQuery …
At times you need the fetch the value of the property from the existing ruleset and then make the modifications based on some logic.
We can alter a different DOM attribute of the element by combining it with the content property, we can change the content (but not other properties, like margin or color) of pseudo elements dynamically.
Did you enjoy reading this article? I'd love to hear your thoughts. Shoot me an email or send me a tweet if you've got any comments.
‹ Back to Home