I am looking for a simple JavaScript example that updates DOM.
Any suggestions?
Here is a short pure-javascript example. Assume you have a div with the id "maincontent".
var newnode = document.createTextNode('Here is some text.');
document.getElementById('maincontent').appendChild(newnode);
Of course, things are a lot easier (especially when you want to do more complicated things) with jQuery.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With