原生js实现点击变色或者tab选项卡

  function tab(btn) {
    for (var i = 0; i < btn.length; i++) {
      btn[i].index = i;
      btn[i].onclick = function () {
        //alert(this.index );
        for (var j = 0; j < btn.length; j++) {
          btn[j].classList.remove("isCheck")
         // boxlist[j].style.display = "none";
          btn[this.index].classList.add("isCheck");
         // boxlist[this.index].style.display = "block";
        }
      }
    }
  }

  onload = function () {
    let btn = document.getElementsByClassName("nav-icon");
    tab(btn ,参数)
  }

你可能感兴趣的:(Javascript)