-4

can someone please tell me how to remove div element using javascript. I'm on a Shopify theme edit.

I need to this to be or

2 Answers2

0

First, get the div that you need to remove.

and then remove the div from its parent.

var element = document.getElementById("childDiv");
element.parentNode.removeChild(element);
Mahbub Moon
  • 491
  • 2
  • 8
0

Here is some example hope this will help you!

var btn = document.getElementById('btn');
btn.onclick = function () {
    document.getElementById('did').remove();
    this.remove();
};
<div id='did'>
<p id='pid'>Hello World</p>
<input id='btn' type="submit" value='REMOVE THAT!!!'/>
</div>