您可以使用$$函数按类获取元素: the $$ function。$$(".myclass") 这个函数会给你一个可以迭代的元素数组。它允许您使用任何 CSS 选择器来获取元素:$$("li.myclass") $$("p#test")