-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
  • 1
    post your code. Whatever you have done Commented Nov 11, 2019 at 6:14
  • How are you targeting the div to be removed ? what identifier are you going to use ? Commented Nov 11, 2019 at 6:23

2 Answers 2

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);
Sign up to request clarification or add additional context in comments.

Comments

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>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.