Here is my brief HTML document.
Why is Chrome Console noting this error:
\"Uncaught TypeError: Cannot call method \'appendChild\' of
nul
The body hasn't been defined at this point yet. In general, you want to create all elements before you execute javascript that uses these elements. In this case you have some javascript in the head section that uses body. Not cool.
You want to wrap this code in a window.onload handler or place it after the tag (as mentioned by e-bacho 2.0).
Javascript Tests
See demo.