I Googled a lot about creating multiple items with appendChild
, but I’m not understanding how it works. My appendChild
just replaces instead of adding many.
var startGame;
var cards = 16;
var newDeck = [];
startGame = function(){
var startBtn = document.getElementById('start');
var board = document.getElementById('game-board');
var backside = document.createElement("div");
backside.className = 'card';
startBtn.onclick = function(){
removeButton = document.getElementById("start");
removeButton.parentNode.removeChild(removeButton);
for(var i = 0; i < cards; i++){
board.appendChild(backside);
}
};
};
I also read you can do this with innerHTML
, but that leaves me confused as well. Does anyone have a more detailed explanation on how to make this work?
id
attribute unique for the clone. – Eelworm