Pseudo-element CSS Dynamically Using JavaScript
Is it possible to set the CSS of a pseudo-element dynamically? For example: jQuery dynamically styling help container $('#help').css({ 'width' : windowWidth - xOffset, 'hei
Solution 1:
You can't do it directly through jQuery.
Look at this question: Setting CSS pseudo-class rules from JavaScript
@Box9's answer is probably the one you should actually use:
I threw together a small library for this since I do think there are valid use cases for manipulating stylesheets in JS.
Solution 2:
Rather than setting the width and height using .css()
, you should just use .width()
and height()
directly.
Post a Comment for "Pseudo-element CSS Dynamically Using JavaScript"