Question: How can I implement [prepend](http://api.jquery.com/prepend/) and [append](http://api.jquery.com/append/) with regular JavaScript without using jQuery?

Answer: 
Perhaps you're asking about the [DOM methods](http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-184E7107) `appendChild` and `insertBefore`.

```
parentNode.insertBefore(newChild, refChild)

```

> 
> Inserts the node `newChild` as a child of `parentNode` before the
>  existing child node `refChild`. (Returns `newChild`.)
> 
> 
> If `refChild` is null, `newChild` is added at the end of the list of
>  children. Equivalently, and more readably, use
>  `parentNode.appendChild(newChild)`.
> 
> 
>
I added this on my project and it seems to work:

```
HTMLElement.prototype.prependHtml = function (element) {
    const div = document.createElement('div');
    div.innerHTML = element;
    this.insertBefore(div, this.firstChild);
};

HTMLElement.prototype.appendHtml = function (element) {
    const div = document.createElement('div');
    div.innerHTML = element;
    while (div.children.length > 0) {
        this.appendChild(div.children[0]);
    }
};

```

Example:

```
document.body.prependHtml(`<a href="#">Hello World</a>`);
document.body.appendHtml(`<a href="#">Hello World</a>`);

```