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
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
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);
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>