Skip to content

Instantly share code, notes, and snippets.

@OlofT
Created May 9, 2018 05:31
Show Gist options
  • Save OlofT/34db29d4052ed1d7ca9f68b9037c412d to your computer and use it in GitHub Desktop.
Save OlofT/34db29d4052ed1d7ca9f68b9037c412d to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/deyigemuza
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
document = window.document;
var styleSheet = document.createElement("style");
styleSheet.setAttribute('type', 'text/css');
var head = document.getElementsByTagName("head")[0];
head.appendChild(styleSheet);
styleSheet = document.styleSheets[document.styleSheets.length - 1];
styleSheet.insertRule(".workingClass { dontAddThis }", 0);
var rule = styleSheet.cssRules[0];
var style = rule.style;
style.borderColor = "green";
console.log("working fine in the browser:");
console.log(rule.cssText);
</script>
<script id="jsbin-source-javascript" type="text/javascript">
document = window.document;
var styleSheet = document.createElement("style");
styleSheet.setAttribute('type', 'text/css');
var head = document.getElementsByTagName("head")[0];
head.appendChild(styleSheet);
styleSheet = document.styleSheets[document.styleSheets.length - 1];
styleSheet.insertRule(".workingClass { dontAddThis }", 0);
var rule = styleSheet.cssRules[0];
var style = rule.style;
style.borderColor = "green";
console.log("working fine in the browser:");
console.log(rule.cssText);</script></body>
</html>
document = window.document;
var styleSheet = document.createElement("style");
styleSheet.setAttribute('type', 'text/css');
var head = document.getElementsByTagName("head")[0];
head.appendChild(styleSheet);
styleSheet = document.styleSheets[document.styleSheets.length - 1];
styleSheet.insertRule(".workingClass { dontAddThis }", 0);
var rule = styleSheet.cssRules[0];
var style = rule.style;
style.borderColor = "green";
console.log("working fine in the browser:");
console.log(rule.cssText);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment