divs used as buttons don’t stay active

robbie-robertson.com/uw_test/poverty-simulation.html

that is the site i’m working on… the code that is supposed to make the divs stay active doesn’t do it. i suspect it’s because my divs are all grouped by class and im trying to split them up in 3’s. i tried to use session storage to store the individual divs active state by id but it didnt work. thanks in advance.


var active = 0;

var btns = document.getElementsByClassName("card");
// Loop through the buttons and add the active class to the current/clicked button
for (var i = 0; i < btns.length; i++) {
// sessionStorage.getItem(this.className); 
btns[i].addEventListener("click", function() {
  var current = document.getElementsByClassName("active");

  // If there's no active class
  if (current.length > 0) {
    current[0].className = current[0].className.replace(" active", "");
  
  }

  // Add the active class to the current/clicked button
  this.className += " active";
  // sessionStorage.setItem(this.className, active);
});
} 

here is the rest of the javascript.

https://robbie-robertson.com/uw_test/scripts/main.js