Why doesn't the color change when adding a class?

  • 0
    I add a new class to the element, but the color does not change.
    How can I change the color by adding or removing this class?
    JavaScript Anonymous, Sep 4, 2020

  • 1 Answers
  • 0
    ssList.add ("red");

    In this case, a class without a dot is written.

    document.querySelector(".box").addEventListener("click", function(e) {


    It is very easy to remember this. If you cannot specify anything besides a class, then you do not need to specify ".", Which indicated that this is a class.

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!