Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Remove an Element

DOM & Eventsmedium

Course · Section 7: JavaScript in the Browser: DOM and Events · Lecture 76: Selecting and Manipulating Elements

Inside `<div id='parent'>` there are two spans. Remove the one with class `remove-me`, leaving the `keep` span in place.

Sample tests

Input: only one span remains
Output: assertion passes

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Removing via parent.removeChild requires a parent reference; remove() is simpler.

Learning resources

  • MDN: Element.remove
Approach & explanation (try first)

Element.remove() detaches the node from the DOM in one call.

Loading...
⌘/Ctrl + Enter

Run your code to see results.