JS chaining pattern to insert elements into the DOM
<p>I am struggling to make the pattern below work. I'm not interested in using a library.</p>

<pre><code>function _createElement(tagNm, attr){
    var el = document.createElement(tagNm);
    for(var at in attr){
        el.setAttribute(at, attr[at]);
    }
}
//below function is not correct just for giving you idea
function _append(ele){
    this.appendChild(ele)
    return this;
}
// I would like to be able to achive following chaining patter with this.
var div = document.getElementById('div');
div._append( _createElement('div', {
    id : 'parent', className: 'parent'
})).appendChile( _createElement('div', {
    id : 'child', className: 'child'
}));
</code></pre>
