function foo (str){ var div = document.getElementById('dump'); var p = document.createElement('p'); p.appendChild(document.createTextNode(str)); div.appendChild(p); }