Delete elements with a particular class name (using javascript)?
<p>I was trying to delete elements with a particular class name, but it doesnt work. Any idea why?</p>

<pre><code>function delete_elems(){
    var my_elems = document.getElementsByClassName("my_elem");
        for(k=0; k&lt;my_elems.length; k++){
            my_elems[k].parentElement.removeChild(my_elems[k]);
        }

}
</code></pre>

<p>I also tried:</p>

<pre><code>function delete_elems(parentElem){
    var my_elems = document.getElementsByClassName("my_elem");
        for(k=0; k&lt;my_elems.length; k++){
            parentElem.removeChild(my_elems[k]);
        }

}
</code></pre>
