During debugging (at least) it would be convenient to write log messages to the window
(rather than to the console with console.log)
Using something like
document.getElementById("info").innerHTML = 'hello world';
only lets me write one time, the next time I use this it overwrites. I there a way to "append"?
I also tried something like:
mydiv.insertAdjacentHTML('afterend', '<p>'+sometext+'</p>');
after declaring <div id="mydiv"></div>
in the body.
Still, I wonder if there is an easier way.
(Of course I could keep the text to be written in memory and append to it.)
This should be possible using jQuery .append. See http://api.jquery.com/append/ (http://api.jquery.com/append/)
document.getElementById("info").innerHTML
This is plain DOM programming. Boring. Long-winded. I recommend you use jQuery instead:
$('#info').text('bla');
Both statements set the content of the HTML tag.
There are several methods in jQuery to append. But the simplest way is to just keep your text in a string:
var text = 'Hello';
$('#info').text(text);
Add to the string and update the HTML tag again:
text += ' World!';
$('#info').text(text);
Or you can do this
$('#info').text( $('#info').text() + ' more text' );