Appending elements to parents that called the createElement() function <p>I am trying to create a function that creates an element and takes the parameter of <code>element</code> (an object).</p> <pre><code>var createElement = function(element) { var newElement = document.createElement(element.type); var newElement_textNode = document.createTextNode(element.text); newElement.appendChild(newElement_textNode); element.parent.appendChild(newElement); }; </code></pre> <p>The only problem is I want to append the element to the element that called the function. For example: </p> <pre><code>var list = document.getElementById('ulList'); list.createElement({ type: 'li', text: 'Another item' }); </code></pre> <p>My question is how do I append it to the element that called the function, in this case, the ul <code>list</code></p>