The direct parent of your child is markerDiv, so you should call remove from markerDiv like this:
markerDiv.removeChild(myCoolDiv);
Alternatively, you can remove markerNode. Since node was added directly to the video container, it can be removed using:
document.getElementById("playerContainer").removeChild(markerDiv);
Now, the easiest general way to remove a node, if you are absolutely sure that you have embedded it in the DOM, is:
markerDiv.parentNode.removeChild(markerDiv);
This works for any node (just replace markerDiv with another node) and immediately find the parent from the node to trigger removal from it. If you are not sure if you added it, double check if there is a parentNode-null before calling removeChild.
source share