Menu

Updating CSS Rules in Stylesheet

Help
Tim A
2016-02-04
2016-02-07
  • Tim A

    Tim A - 2016-02-04

    Hello at all,

    i got following question.

    I have a CSSStyleSheet object, which I need to change at runtime. But the Implementation don't have a method like updateCSSRule(String selector, CSS CSSRule)

    How can I do this? I hope anyone can help me.

    Thanks!

     
    • RBRi

      RBRi - 2016-02-07

      On Thu, 04 Feb 2016 08:45:51 +0000 Tim A wrote:

      Hello at all,

      i got following question.

      I have a CSSStyleSheet object, which I need to change at runtime. But the Implementation don't have a method like updateCSSRule(String selector, CSS CSSRule)

      How can I do this? I hope anyone can help me.

      Thanks!

      You can do something like:

      1. getCSSRules() to get a CSSRuleList
      2. determine the index of the rule you like to change inside this list
      3. call deleteRule with the given index
      4. insertRule
        InsertRule requires the rule as string, but i guess it is simple to construct the string out of you selector and CSSRule.

      The w3c.dom.css API is really old and seems to be a bit strange these days....

      Hope this helps. If not please open a issue, maybe i can add some support for your case.

      RBRi
      --------------------------
      WETATOR
      Smart web application testing
      http://www.wetator.org
      
       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.