JS in a lot of DOM methods are for the array, but sometimes we will get some pseudo-array, at this time to manipulate the pseudo-array, then we must transform the pseudo-array into arrays, the following through the method of apply () demo An example, for your reference (the following is part of the code):
</Head><Body><span>Span</span> <span>Span</span><P>Ppp</P><span>Span</span> <span>Span</span><P>Ppp</P><span>Span</span> <span>Span</span><P>Ppp</P><Script> functionT (tagname,context) {context=Context||document; returnContext.getelementsbytagname (tagName); } varspans=T ('span' ); Console.log (spans);//Pseudo-Array vararr=[]; //declares a new arrayarr.push.apply (Arr,spans); //The second argument using apply is a method of an array (a pseudo-array) that converts it into a group.Console.log (arr);//ArrayArr.foreach (function(v,i) {V.style.border='1px solid Red'; //a simple way to add a style is to use an array, etc. })</Script>
The result is:
Convert pseudo-arrays to arrays using the Apply method