I know that jQuery cannot directly manipulate CSS pseudo elements, and I've already read a bunch of posts here that don't answer my question.
I need to modify the CSS of a pseudo element with the value of a field.
My project has an icon displayed before text using :before. I need that icon's font-size to dynamically change as the user changes the value in a field.
I have the basics of the script down, but I just can't get it to change the font size with each change. For example (#base_size is the field with the integer value, a:before is the pseudo element that has inserted the icon):
$('#base_size').change(function() {
var baseSize = $(this).attr('value');
document.styleSheets[0].insertRule('.item a:before { font-size:' + baseSize + 'px !important; }');
});
This particular jQuery will change the font size, but only the first time. Further changes in #base_size don't affect the pseudo element, but each change does create a new CSS rule. Oddly, Chrome dev tools shows ".item a::before" (one for each change) with two colons and no declarations.
I'm probably going about this all the wrong way. I will be very grateful for any help!