$(document).on("click", ".rimuovi-riga-investimenti", function(){
    var tr = $(this).closest('tr').prop('id');
    $("#"+tr).remove();
    var count_righe = $("#count_righe_tabella_investimenti").val();
    var count_righe_now = (count_righe*1 - 1)*1;
    $("#count_righe_tabella_investimenti").val(count_righe_now);
    ricrea_indici_investimenti(count_righe_now);
    calcola_totale();
});

function ricrea_indici_investimenti(row){
    var rows = $("#investimenti tbody tr");
    var counter = 1;
    rows.each(function(){
        var id = $(this).attr("id");
        if(id.substring(0, 21) == "categoria_interventi_"){
            $(this).attr("id", "categoria_interventi_"+counter);
            if(counter == row){
                return;
            }
        }
        counter++;
    })
}