I'm making an application where the JavaScript code is all in the head but I need to output the data into a table in the body.
I'm currently using the following code from the head which just writes to the body. But it's pretty sloppy, I'd prefer to have it in a table.
document.body.innerHTML = (document.body.innerHTML+'<br />'+place.name);
How would I do this?
'+place.name);`. You can create elements with document.createElement('div') [example for div, just put any tag name in there] `document.body.appendChild( document.createTextNode('Hello World') );` will just add the text Hello World to the doc. You can append a text node to a div, then append that div to the document (or some other element). Your example could be done with: `document.body.appendChild( document.createElement('br') ); document.body.appendChild( document.createTextNode(place.name) );` – enhzflep Aug 28 '13 at 23:05