const uldd = document.queryselectorall(".partlast1 ul"); const spancc = document.queryselectorall(".partlast1 div span"); const divbb = document.queryselectorall(".partlast1 div"); const arr = [5, 2, 4, 1, 4, 3]; function haha() { this.children[1].style.animation = "rotation1 0.4s linear 0s forwards"; uldd[this.getattribute("index")].style.animation = "huad_down" + arr[this.getattribute("index")] + " 0.4s ease 0s forwards"; this.removeeventlistener("click", haha); this.addeventlistener("click", hehe); } function hehe() { this.children[1].style.animation = "rotation2 0.4s linear 0s forwards"; uldd[this.getattribute("index")].style.animation = "shouqi_up" + arr[this.getattribute("index")] + " 0.4s ease 0s forwards"; this.removeeventlistener("click", hehe); this.addeventlistener("click", haha); } for (var i = 0; i < divbb.length; i++) { divbb[i].addeventlistener("click", haha); }