Bring Node to Top
myEl.parentNode.appendChild(myEl);
This will make an element the top most of all of its siblings…
document.body.innerHTML += `
<div>
<button>one</button>
<button>two</button>
<button>three</button>
<button>four</button>
</div>
<style>
button { display: block; cursor: pointer; }
</style>
`;
document.addEventListener('click', e => {
if (e.target.tagName === 'BUTTON') {
e.target.parentNode.appendChild(e.target);
}
});
Clicking on any button will bring it to the top most position within its parent.