1

EDIT: This couldn't be a duplicate of Change the :before selector from javascript as I'm trying to insert a rule and not to update an existing one. So for anyone searching for the the same problem of insertingRules with this error wont find the suggested duplicate! I didn't and it doesn't necessarily help! END EDIT!

I'm trying to insert a webkit specific rule into a css file through javascript. The rule I am trying to insert is:

progress[value]::-webkit-progress-value:after{background-color: rgba(255,255,255,0.7);}

What the browser doesn't accept is the :after selector. Is there another way to target this specific rule including :after?

I'm inserting the css this way which works fine for all other rules I have. Its only this one that fails!

var sheet = document.styleSheets[2], index = 0;

sheet.insertRule('progress[value]::-webkit-progress-value:after{background-color: rgba(255,255,255,0.7);}', index);
Community
  • 1
  • 1
just_user
  • 11,769
  • 19
  • 90
  • 135
  • Possible duplicate of [Change the :before selector from javascript](http://stackoverflow.com/questions/22659170/change-the-before-selector-from-javascript) – Shrabanee Jun 01 '16 at 08:54
  • 1
    Doesn't `after` always need `content`? –  Jun 01 '16 at 09:40
  • 1
    @titi23 thanks for the down vote, and no its not the same to update a rule as inserting new ones. – just_user Jun 01 '16 at 09:49
  • @torazaburo do you mean that I should add content to the rule I am trying to insert? Tried and didn't help. Other :after rules that I am inserting the same way works fine. – just_user Jun 01 '16 at 09:54

0 Answers0