<div style="background: gray">div</div>
<script>
document.body.children[0].onmouseover = function () {
if (!document.getElementById('di')) {
this.insertAdjacentHTML('afterBegin', '<button id="di">click</button>');
}
}
document.body.children[0].onmouseout = function (e) {
e = e || event;
var rt = e.relatedTarget || e.toElement;
while(rt && rt != this) {
rt = rt.parentNode;
}
if (rt == this ) {
return;
} else if (document.getElementById('di')) {
this.removeChild(document.getElementById('di'));
}
}
</script>