<div id="filters"></div>
<div id="available">
<span class="badge badge-pill" onclick="addFilter()">Label</span>
</div>
function addFilter(event) {
document.getElementById("filters").appendChild(event.target);
event.target.removeEventListener('click', addFilter);
event.target.addEventListener('click', removeFilter);
}
function removeFilter(event) {
document.getElementById("available").appendChild(event.target);
event.target.removeEventListener('click', removeFilter);
event.target.addEventListener('click', addFilter);
}
So, removeEventListener doesn't work is this case. Is there any way that I can accomplish to "toggle" the onclick event?