There are cards with the class "advantages-content_item", when you click on them, you need to assign the class "active" to this card; The same class should be removed from the previous card when clicking on a new one.

let advitem = document.getElementsByClassName('advantages-content_item'); for (let i = 0; i < advitem.length; i++) { advitem[i].onclick = function() { for (let j = 0; j < advitem.length; j++) { advitem[j].classList.remove("active"); }; this.classList.toggle("active"); }; }; 

Reported as a duplicate at Grundy. javascript Nov 18 '18 at 8:45 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    0