When the button is clicked, a new div is added. Each time it is clicked an additional div is added. The div have following properties:
I hope these pic might help you:
HTML:
<button onclick="newDiv()">Add Box</button>
<div id="parent"></div>
JS:
function newDiv() {
var divElem = document.createElement("div");
elementAttr.setAttribute('class','divclass');
//if you want to add text inside
//var imText = document.createTextNode("Hello Wolrd");
// divElem.appendChild(imText);
//you need a parent Div to put this inside
var parent = document.getElementById("parent");
parent.appendChild(divElem);}
just make a css class with a style that you want so when a div is made it will get a style.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.