How can you remove an HTML element using JavaScript?

  • remove()
  • hide()
  • deleteElement()
  • innerHTML = ''
You can remove an HTML element using the remove() method in JavaScript. For example, if you have an element with the ID elementToRemove, you can remove it using document.getElementById('elementToRemove').remove();. This method completely removes the element from the DOM (Document Object Model).
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *