0
Create a red div cube with JS
I need to create a div with: width: 40px height: 40px background-color: red by a js string, can you help me please? This is my code: var iDiv = document.createElement("div"); iDiv.setAttribute("id","place"); iDiv.style.backgroundColor = "red"; iDiv.style.width = "40px"; iDiv.style.height = "40px";
2 Answers
+ 3
just add document.body.appendChild(iDiv);
if output error, put js code into <script> tag
+ 1
thank you