Let's continue talking about how to access and manipulate on multiple elements, but before we consider
another dumb method, I would like to show you another array method, which is very popular and useful
when we deal with a race.
So I want to introduce you a right for each method, for each method executes a provided function once
for each array element.
In order to better understand what I'm talking about, let's go back to brackets and at first get rid
of these lines of codes and leave only variable icons with get elements by class name method that's
used for each method with variable icons, which in this case is a collection.
So right.
I can start for each, for each method uses anonymous function as a parameter and this function itself
uses its parameters.
Generally, you can pass here three parameters.
First one is for array item, which is the value of the current element in this case.
Right icon.
Generally, it's a standard way to use array name in plural form and the item of array in singular form.
So that's why I'm using icon here.
Second parameter of function is index, which returns index number of items, and the third parameter
is array itself which returns.
And right.
This is the general structure of foreach method, but commonly it's used with only first parameter,
which refers to item of a right.
But anyway, let's log it in council.
Right.
Cancel that log
in order to avoid typing, cancel the logs for every parameter.
We can just separate them by commas and use only one.
Cancel that log.
So right here inside the parentheses icon, that index and.
Right.
Reload the page and you see that we have an error, which we have already seen previously, and it's
definitely clear why we have just got it far, which is an array method.
It works with a race.
And in this case, Aitken's is just a collection.
So in order to use forage for icons, we need to transform it into a right.
And for that we can use a red dot from method, which we have already seen previously.
So right away that from and inside parentheses plus icons.
Then reload, and here we have results where you can find three parameters, which we have passed inside
a function.
First one, we have an item or current element, then the index number and write itself.
So it proves that function was executed according to the number of items, we had six items and therefore
function was executed six times in order to see it better.
That leave just one parameter icon, then reload and we have six items of an array.
OK, let's move on and talk about another dumb method, which I like at elements by class name method
is used to get and manipulate on multiple HDMI elements.
I'm talking about get elements by Takanabe method.
This method returns a collection of all elements in the document with the specified target name as an
e-mail collection.
All right, let's go back to Brackett's and get rid of these codes because I don't need them anymore.
Let's get access on these elements.
So create variable ice and use get elements by TAKANABE Method write document that get elements by Tognum
and inside the parentheses indicate the taqaddum of least elements so right élite then log it in council.
Right.
Cancel that log Ellyse.
Reload and here we have all these elements, if we drop down it, you will see that it's again an e-mail
collection.
The result is an exact similar as it was in case of get elements by class method.
So I'm not going to waste time on that because I think it will be boring for you.
I just want to say that these two methods get along by class name and get elements by tag name work
in the exact same way.
The main difference is that you get elements by class name select elements with specified class name
and get elements by tag, name, select elements using specified techniques.
All right, that's it.
See you in the next video.