Property 'index' does not exist on type' Element'

the project starts up with an error, but you can run

by re-saving the js file.
toggleDetails() {
      var item = document.getElementsByClassName("list-wrapper");
        var next = document.getElementsByClassName("ico-next");
      var divcard = document.getElementsByClassName("divcard");
      for (var i = 0; i < item.length; iPP) {
          item[i].index = i;
          item[i].onclick = function () {
              var num = this.index;
              if (divcard[num].style.display === "block") {
                  next[num].style.transform = "rotate(0)";
                  divcard[num].style.display = "none";
              } else {
                  next[num].style.transform = "rotate(90deg)";
                  divcard[num].style.display = "block";
              }
          }
      }
  }
Apr.02,2021
The error message

is already obvious. Element does not have the field index. Item [I] is an object. There is no index field in your object. Of course, an error is reported.

Menu