I have the below code to find elements with their class name:
// Get the element by their class name
var cur_columns = document.getElementsByClassName(\'colu
In pure vanilla Javascript, without jQuery or ES6, you could do:
const elements = document.getElementsByClassName("my-class");
while (elements.length > 0) elements[0].remove();
It's very simple, one-liner, using ES6 spread operator due document.getElementByClassName returns a HTML collection.
[...document.getElementsByClassName('dz-preview')].map(thumb => thumb.remove());
Using ES6 you could do like:
const removeElements = (elms) => elms.forEach(el => el.remove());
// Use like:
removeElements( document.querySelectorAll(".remove") );
<p class="remove">REMOVE ME</p>
<p>KEEP ME</p>
<p class="remove">REMOVE ME</p>
Yes, you have to remove from the parent:
cur_columns[i].parentNode.removeChild(cur_columns[i]);