複製程式碼程式碼如下: function getElementsByClassName(n) { for (var i=0; i{ if (allElements[i].className == n ) { classElements[classElements.length] = allElements[我]; } } 回傳類別元素; } var redClassElements = getElementsByClassName('aa'); for (var i=0; i //做某件事