// Input mode
var list = document.getElementById('thelist');
var element = document.createElement("LI");
First off, we get an element named ‘thelist’ — this is the OL or UL tag enclosing your list. Then, we create a new element. In this case, it’s a “LI” element. Next, we use the innerHTML property to set what goes inside the LI and /LI tags — in other words, innerHTML is what’s inside the tags. Finally, we use the appendChild function to add the element we created to the list.
The end result can be seen and tested here.
Overall, it’s a fairly simple but highly effective little technique that you can add to your bag of tricks.