Elements parent() - KirkGarcia182/domExtend GitHub Wiki
Gets the parent element of the element, you can specify the depth on which how many generations of parent element you want to get from the current element. The highest parent you can get is document because document doesn't have any parent.
element.parent([depth]);
depth (Optional) - is an Integer
denoting how many generations of parent element you want to get from the current element. Default value is 1, which means the first generation parent of the current element.
The parent element denoted by the depth or the document, the highest parent in the DOM
<!DOCTYPE html>
<html>
<head>
<title>domExt Examples</title>
</head>
<body>
<div id="app">
<div class="menus">
<ul id='menuList'>
<li><a class='menuLink'>Menu 1</a></li>
<li><a class='menuLink'>Menu 2</a></li>
<li><a class='menuLink'>Menu 3</a></li>
</ul>
</div>
</div>
<script type="text/javascript" src="domExt.js"></script>
<script type="text/javascript">
window.$ = document;
let link = $.byId('app');
console.log(app.parent());
/* Result
<body>...<body>
*/
console.log(app.parent(1));
/* Result
<body>...<body>
*/
console.log(app.parent(2));
/* Result
<html>...<html>
*/
console.log(app.parent(9999999999));
/* Result
#document
*/
</script>
</body>
</html>