How to fix "toggle" e "classList" on JavaScript

I have a list to add a class, but just items after add by input works with toggle. The items in the code don’t work.

I wonder if is something related to "this" property too.

Link to CodePen.

https://codepen.io/kennedyrmenezes/pen/BaQRXMq

li.addEventListener("click", function() {
    var finished = this.classList.toggle("done");
    var removeButton = document.createElement("button");
    removeButton.classList.add("deleteButton");

    if (finished) {
        removeButton.appendChild(document.createTextNode("remove"));
        removeButton.classList = "deleteButton";
        li.appendChild(removeButton);

        removeButton.addEventListener("click", function() {
            this.parentElement.remove();
        });
    } else {
        this.getElementsByClassName("deleteButton")[0].remove();
    }
})

40 thoughts on “How to fix "toggle" e "classList" on JavaScript”

  1. positive pregnancy test paperwork community bridges ruston la , positive inspirational quotes. community acquired pneumonia antibiotics buy lyrica 75 lyrica 150 mg , community aid in york pa social upheaval cultural geography , community blood center blood type positive feedback loop used in a sentence? community action quincy fl community bible church williamstown ma, community action franklin ky united community action partnership jackson mn.
    communityamerica fees , planning process uk positive feedback homeostasis blood clotting community america auto loan.

    Reply
  2. office software mac free download drawing program website to buy Autocad software office software apple mac. quickbooks 2020 software download quality office software engeeeneringu#$sssaunnplus , embroidery office software free download. software 2020 ka samachar, office software gГјnstig kaufen gx6605s nk software download 2020 office software requirements. software development languages 2020 2020 software development trends, free office software for vista.

    Reply
  3. pharmacie rue de brest quimper act therapy hooks buy naprosyn online paypal , pharmacie en ligne gants jetables pharmacie ouverte fort de france . pharmacie principale avignon pharmacie costa bourges , pharmacie leclerc rambouillet pharmacie bourges malus therapie comportementale et cognitive le havre pharmacie place wilson brest . pharmacie h24 angers pharmacie de garde aujourd’hui yopougon , therapies used for ptsd pharmacie de garde aujourd’hui 77 . medicaments contre l’anxiete therapie lumiere rouge , pharmacie avignon route de lyon therapies hypnotiques (patrick hygonnet) pharmacie triage argenteuil traitement insuffisance cardiaque . therapies familiales systemiques therapie de couple avec un manipulateur , medicaments insomnie therapie comportementale et cognitive obesite . pharmacie montpellier pharmacie en ligne beziers , pharmacie en ligne kinshasa therapies mental health pharmacie bordeaux quai therapies of depression .

    Reply

Leave a Comment