Skip to content

Confusing css class name changes in javascript #13

@Tymski

Description

@Tymski

If I understood it correctly, the code overrides the className with every loop iteration.
b.className = "button"; is used to remove the "pressed" class.

To make it more clear, you could use the add and remove methods of classList property.
instead use buttonElement.classList.remove('pressed');
also utilize buttonElement.classList.add('pressed'); when it's needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions