delete html with javascript
var div = document.getElementById('div-01');
div.remove();Removing an element is much easier, as it only requires the element's ID.
1. function removeElement(elementId) {
2. // Removes an element from the document.
3. var element = document. getElementById(elementId);
4. element. parentNode. removeChild(element);
5. }
Example:
<h1>The remove() Method</h1>
<p>The remove() method removes the element from the DOM.</p>
<p id="demo">Click the button, and this paragraph will be removed from the DOM.</p>
<button onclick="myFunction()">Remove paragraph</button>
<script>
function myFunction() {
var myobj = document.getElementById("demo");
myobj.remove();
}
</script>document.querySelector('selector').remove();
Also in JavaScript:
- mapping a pojo with json via gson
- hot to start cypress
- javascript node await .click
- responsive calc height react native
- js analyse img color
- jquery find
- js logical operators
- o que é jsonm
- Javascript parse json string
- how to format unix timestamp javascript
- Qwiklabs Assessment: Working with Regular Expressions
- how to know type of dom element in js
- import slider material ui
- socket io get ip
- fixed header on scroll vuejs
- remove a specific element from an array
- javascript infinite loop
- generate express app
- Material-ui camera icon
- javascript check if is nan
- upload form with doc type in ajax
- class component params in react
- react router dom push
- page refresh jquery on click