3 ms·
Wouldn't these two lines of code do the same thing? var addCSS = (css) => { window.document.styleSheets[0].insertRule(css, window.document.styleSheets[0].css
by osoba 10y ago
Wouldn't these two lines of code do the same thing?
var addCSS = (css) => { window.document.styleSheets[0].insertRule(css, window.document.styleSheets[0].cssRules.length); };
addCSS('.x { color: red; width: 5px; }');
Test examples (+ another version that can add multiple selectors in the same line): https://jsfiddle.net/xkLnj9st/ https://jsfiddle.net/xkLnj9st/