In my program below I am getting the parent node game 1
and then removing one of the two child nodes, depending on which one is clicked. I currently have two event listeners, with two separate functions for removing one child vs the other. It doesn't feel very dry to me, and I think I could benefit from having someone skilled in JS take a look at this and show me how this could be more easily accomplished.
var firstWinner = document.getElementById('game1');
function removefirst() {
firstWinner.removeChild(firstWinner.childNodes[0]);
}
function removeSecond() {
firstWinner.removeChild(firstWinner.childNodes[1]);
}
var gameOneNodes = document.getElementById('game1').childNodes;
gameOneNodes[1].addEventListener('click', removefirst, false)
gameOneNodes[0].addEventListener('click', removeSecond, false)