I am trying to delete a hidden element. I have tried the following codes but it always returns the parent as undefined.
attempt one
var timeLeft = document.getElementById("time");
timeLeft.document.removeChild(timeLeft);
attempt two
var timeLeftBody, timeLeft;
timeLeftBody = document.getElementsByTagName("body")[0];
timeLeft = document.getElementById("time");
timeLeft.timeLeftBody.removeChild(timeLeft);
removeChild()only works on an element that directly contains the child —document.removeChild(hdr)won’t work unless the document directly contains thetimeelement (which is impossible, unlesstimeis thehtmlnode).Try: