the javascript onclick script changes the class on an element that does not contain the specified class

Change your class selector to querySelectorAll.

document.getElementById("myId").addEventListener("click", addClass);
function addClass(event) {
    if( != 'button') {
    var buttons = document.querySelectorAll('.btn-level-1.clicked');
        for (var i = 0; i < buttons.length; i++) {
        buttons[i].classList.remove('clicked'); }

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top