remove elements that were fetched using querySelectorAll?

20 days ago23k times

We can remove elements that were fetched using querySelectorAll by iterating through the NodeList and calling the remove() method on each element. Here is an example:

// Fetch the elements to remove
const elements = document.querySelectorAll('.class-name');

// Iterate through the elements and remove them
elements.forEach(element => {
    element.remove();
});

Add Answer

Add a codeAdd Code
Remove adsremove

Latest codes

view all

Latest Snippets

view all