Why won't this script append a child div element?
<p>When I click on the p element with an onclick attribute calling the make_child function I would expect it to append a div element when ever it is clicked but it seams to be only appending a text node to the paragraph element what is the cause of this?</p>

<pre><code>&lt;script type="text/javascript"&gt;
function make_child(text, id, type) {
    var text = document.createTextNode(text);
    var target = document.getElementById(id);
    var add = document.createElement(type);
    var addtext = add.appendChild(text);
    target.appendChild(addtext);
}
&lt;/script&gt;

 &lt;p id="changeme" onclick="make_child('I have changed', 'changeme', 'div')"&gt;Click me to change&lt;/p&gt;
</code></pre>
