Elements prependTo() - KirkGarcia182/domExtend GitHub Wiki
Inserts the element to the first childNode of a parent element.
element.prependTo(node);
node - A Node
where the current element will be inserted as the first child of.
The element you just manipulated so you can chain these methods.
<!DOCTYPE html>
<html>
<head>
<title>domExt Examples</title>
</head>
<body>
<div id="app">
<div class="menus">
<ul id='menuList'>
<li><a>Menu 1</a></li>
<li><a>Menu 2</a></li>
<li><a>Menu 3</a></li>
</ul>
</div>
</div>
<script type="text/javascript" src="domExt.js"></script>
<script type="text/javascript">
window.$ = document;
let menuList = $.byId('menuList');
let menuLi = $.ce('li');
let menuLink = $.ce('a').html('Menu 4').prependTo(menuLi);
console.log(menuList);
/* Result
<ul id='menuList'>
<li><a>Menu 4</a></li>
<li><a>Menu 1</a></li>
<li><a>Menu 2</a></li>
<li><a>Menu 3</a></li>
</ul>
*/
</script>
</body>
</html>