I am attempting to use JavaScript to add another list item to an unordered list. I want the list item to display dynamic content based on a pre-existing variable. While I can successfully append a list item by using a string, things go awry when I try to incorporate a variable.
//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 issue arises with this section of code:
var textnode = document.createTextNode(playerInput.value);
When I used a hardcoded string instead (as shown below), it worked without any problems:
var textnode = document.createTextNode("New Player");