-2

I have a simple script adding to a UL via a button but it's not working

<input type = "text" id ='textbox'/>
<button onclick="addPeople()">Add Players</button>
<ul id='myList'></ul>

<script>
function addPeople() {
    var text = document.getElementById("textbox").value; 
    var li = "<li>" + text + "</li>";
    document.getElementById("myList").appendChild(li);
}
</script>

can someone point me in the right direction?

Justin
  • 137
  • 2
  • 10
  • Youo should search before posting. See this: http://stackoverflow.com/questions/17773938/add-a-list-item-through-javascriptand there are many others for you tyo reference. also see this:http://stackoverflow.com/help – M H Jun 09 '15 at 00:22
  • This is not a valid node for appendChild, it's just a string. `var li = "
  • " + text + "
  • ";` – colecmc Jun 09 '15 at 00:25
  • `document.getElementById("myList").innerHTML += li;` – Drakes Jun 09 '15 at 00:29