Home  »  CheatsheetsCodeProgrammingSnippetsSoftwareTechnology   »   JavaScript Remove Element From the Dom

JavaScript Remove Element From the Dom

Posted: March 10, 2022 | by Michael Bright

JavaScript, remove element:

var element = document.getElementById("myElementID");
element.parentNode.removeChild(element);

Alternate:

var element = document.querySelector('#some-element');
element.parentNode.removeChild(elem);

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.