remove this.class function Javascript
<p>I have a function connected to a class, that lets me remove it by className.
the problem I have is when I have two elements with the same class name. the function close both of the classes and not only the one that's selected.</p>

<p>I think that i use use a element.this function, but when I try it, none of the classes removes.</p>

<p>Any ideas ?</p>

<pre><code> function CloseEvent(){
        var CloseEvent = "close";
        var addClassArr= document.getElementsByClassName(CloseEvent);
        for(var i=0; i&lt;addClassArr.length; i++){
            var addClass = addClassArr[i];
            addClass.addEventListener("click", closebutton, true);
        }       
        function closebutton() {

        var classToRemove = "dice-window-wrapper";
            var elems = document.getElementsByClassName(classToRemove);
            for (var i = 0;  i &lt; elems.length; i--) {
                elems[i].parentNode.removeChild(elems[i])

            }
        } 


    }
    CloseEvent();  
</code></pre>
