The problem is here:
newNode.style = "width:600px;";
Access to the node style object, not the style attribute. This way you can update or set the style object:
newNode.style.width = "600px;";
Or update or set the style attribute:
newNode.setAttribute("style", "width:600px");
Note that in the last example, any existing values ββstored in the style attribute will be overwritten with a new line; To update only one property value, you must use the previous example and specify the specific properties of the style object.
To update element classes:
newNode.className = "newClassName";
Or:
newNode.classList.add("newClassName");
David thomas
source share