According to MDN (https://developer.mozilla.org/en-US/docs/DOM/CSSStyleRule) The CSSStyleRule object’s style property is read-only. Is there a way to be able to reliably modify its style attributes in modern browsers (mainly chrome/safari and firefox, but IE9 would be nice too)?
Semi-related question but is there any way to access comments that are inside of the style rule (edit: and know which rule/selector the comment “belongs” to)? i.e. for this rule:
.my-rule {
/* A Comment */
color: blue;
}
I want to be able to retrieve the /* A Comment */ via javascript.
Here is the UPDATED DEMO
JavaScript :
UPDATE
Since the OP wanted relations with comments, use this code instead :