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