<!DOCTYPE html>
<html lang="en-US">
<head>
<style>
#parent{
position:relative;
margin: 5px;
width: 400px;
height:150px;
border:1px solid red;
}
#child {
position:absolute;
width: 300px;
margin: 10px;
padding: 10px;
border:1px solid black;
}
</style>
</head>
<body>
<div id="parent">
<div id="child">
<p>Open your console and click on the button to display the parent element of the child (this) div.</p>
</div>
</div>
<button onclick="myFunction()">Click Me</button>
<script>
var x = document.getElementById("point");
var elem = document.getElementById("child");
function myFunction(){
console.log(elem.offsetParent);
}
</script> </body>
</html>