Adding HTML elements with Javascript

This is a fairly simple three stage process:

The code to do this would look like this:

var newElement=document.createElement('p');
newElement.textContent='Hi';
document.body.appendChild(newElement);
        

That:

Try it by creating a suitably named function triggered by ONMOUSEDOWN in the BODY or a clickable piece of text. Then try to adapt it for IE by using an IF statement to find out what properties the browser supports.

submit to reddit Delicious Tweet