javascript removechild
javascript
Solution
`removeChild()` only works on an element that directly contains the child -- `document.removeChild(hdr)` won't work unless the document directly contains the `time` element (which is impossible, unless `time` is the `html` node).
Try:
var timeLeft = document.getElementById("time");
timeLeft.parentNode.removeChild(timeLeft);
Problem
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); ```