var elements = document.getElementsByClassName("item");
console.log(elements)
elements[0].classList.add("active");
var elements = document.getElementsByClassName("item");
console.log(elements)
elements[0].classList.add("active");
转载于:https://www.cnblogs.com/guyuedashu/p/11533613.html