xxxxxxxxxx
// Get the parent div element
var parentDiv = document.querySelector("div").parentElement;
// Do something with the parent div element
console.log(parentDiv);
xxxxxxxxxx
// `element` is the element you want to wrap
var parent = element.parentNode;
var wrapper = document.createElement('div');
// set the wrapper as child (instead of the element)
parent.replaceChild(wrapper, element);
// set element as child of wrapper
wrapper.appendChild(element);
xxxxxxxxxx
var parent = element.parentElement;
//OR
e.target.parentNode //target parent
<div>
<span onclick="this.parentElement.style.display = 'none';">x</span>
</div>
xxxxxxxxxx
// Assuming 'element' is the reference to the element for which we want to find the parent
const parentElement = element.parentElement;