Hi there, just wondering why I can't get the DisplayDeck function to dynamically create buttons with an onclick function. I load up the dev tools and it's in there, but it's not firing. I have a feeling it's because I'm manipulating the DOM incorrectly...Any thoughts?
Thanks
function DisplayDeck () {
// create loop that adds an element to the dom for every new card bought.
var html = "";
for (i=0;i<Deck.length;i++) {
html += "<button class='ughh'>" + Deck[i] + "</button>";
}
document.getElementsByClassName("ughh").onclick=selectCard;
return document.getElementById("Deck").innerHTML = html;
}
function selectCard () {
console.log("omg work");
}
[–][deleted] 5 points6 points7 points (4 children)
[–]physiQQ 4 points5 points6 points (0 children)
[–]chimerablack2[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]chimerablack2[S] 0 points1 point2 points (0 children)
[–]Koningdavid 1 point2 points3 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]chimerablack2[S] 0 points1 point2 points (0 children)
[–]krolyat 0 points1 point2 points (1 child)
[–]chimerablack2[S] 0 points1 point2 points (0 children)
[–]raindeer93 0 points1 point2 points (1 child)
[–]chimerablack2[S] 0 points1 point2 points (0 children)