Event '.on (' click ', function () {});' shoot multiple times

1

Good morning, I am working on a page where it has several ul dynamic, that is with li being implemented in them via input and counted through several variables (one for each ul ), and to facilitate I did a function of Exclude li global for all my ul , the function stayed like this:

$('.excluir_li').on('click', function(){
    var elemento = $(this);
    do{
        if(elemento.is('li')){ //Busca o Li a partir do botão de Excluir
            li = true;
        }else{
            elemento = elemento.parent();
        }
    }while(!li);

    switch(elemento.attr('class')){ //Indentifica de qual UL ela faz parte e atualiza o seu contador
        case 'sitProblemaSalvo': contSitProblema--; break;
        case 'SitAprendizagemSalvo': contSitAprendizagem--; break;
        case 'compTecnicoSalvo': contCompetenciasTecnicas; break;
        case 'compGestaoSalvo': contCompetenciasGestao--; break;
        case 'critCompTecnicoSalvo': contCriteriosCompTecnico--; break;
        case 'critCompGestaoSalvo': contCriteriosCompGestao--; break;
        case 'planoAulaSalvo': contPlanoAula--; break;
        case 'estrategiaPlanoAulaSalvo': contEstrategia--; break;
        case 'recursoPlanoAulaSalvo': contRecurso--; break;
        case 'intervencaoPlanoAulaSalvo': contIntervencao--; break;
    }

    elemento.remove();// remove a LI
    }
});

But when I run it, I noticed that the function runs several times (the number of li of the list to be more exact), I researched and tried to use the e.preventDefault(); function, but this was not effective, would someone could you help me?

    
asked by anonymous 03.12.2016 / 13:07

0 answers