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.

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

    if (finished) {
        removeButton.classList = "deleteButton";

        removeButton.addEventListener("click", function() {
    } else {

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

  1. I was wondering if you ever thought of changing
    the structure of your blog? Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so people could connect with it better.

    Youve got an awful lot of text for only having one or two images.

    Maybe you could space it out better?