I am trying to add another li to a ul via Javascript. I want the li to have dynamic content depending on an existing variable. I can get it to append a li using a string no problem. Only when I use a variable things go wrong
//Adding to List
listOfPlayers.style.display = "block";
var node = document.createElement("LI");
var textnode = document.createTextNode(playerInput.value);
node.appendChild(textnode);
listOfPlayersNumerated.appendChild(node);
The problem lays with:
var textnode = document.createTextNode(playerInput.value);
I have tried a literal string (as seen below) and it worked not problem
var textnode = document.createTextNode("New Player");
So I changed it up so you can see where the variable is coming from...
Up top:
Then I just add .value to get the value of that input below:
it will log it in the console but it does not appear on the ul