Answers for "how to empty the div element in html"

0

empty elements in html

<script>
  function func(){
   document.getElementById('div').innerHTML=''
  }
</script>

<button onclick='func()'>Click</button>
<div id="div">
  This disappears
</div>
Posted by: Guest on June-16-2021
0

What is the proper way to empty DIV tag?

const div = document.querySelector('#my-div');
[].slice.call(div.children).forEach(child => div.removeChild(child))
Posted by: Guest on June-24-2021

Code answers related to "how to empty the div element in html"

Browse Popular Code Answers by Language