Encountering an issue when trying to append code to a style element. The error message
Error: Unexpected call to method or property access
is displayed with the following code:
//Creating a new style element
var styleElement = document.createElement("style");
//Setting type attribute
styleElement.type = "text/css";
//Attempting to append code here causes the error
styleElement.appendChild(document.createTextNode("a { color: red; }"));
Can you help identify what mistake I might be making?