WEBVTT

00:01.080 --> 00:07.710
Let's continue talking about how to access and manipulate on multiple elements, but before we consider

00:07.710 --> 00:13.800
another dumb method, I would like to show you another array method, which is very popular and useful

00:13.800 --> 00:15.640
when we deal with a race.

00:16.620 --> 00:25.310
So I want to introduce you a right for each method, for each method executes a provided function once

00:25.320 --> 00:26.670
for each array element.

00:27.390 --> 00:33.810
In order to better understand what I'm talking about, let's go back to brackets and at first get rid

00:33.810 --> 00:41.490
of these lines of codes and leave only variable icons with get elements by class name method that's

00:41.490 --> 00:46.980
used for each method with variable icons, which in this case is a collection.

00:47.250 --> 00:47.970
So right.

00:47.970 --> 00:58.440
I can start for each, for each method uses anonymous function as a parameter and this function itself

00:58.440 --> 01:00.260
uses its parameters.

01:01.470 --> 01:04.050
Generally, you can pass here three parameters.

01:04.710 --> 01:10.710
First one is for array item, which is the value of the current element in this case.

01:10.710 --> 01:11.550
Right icon.

01:13.350 --> 01:20.840
Generally, it's a standard way to use array name in plural form and the item of array in singular form.

01:21.420 --> 01:23.690
So that's why I'm using icon here.

01:24.180 --> 01:32.220
Second parameter of function is index, which returns index number of items, and the third parameter

01:32.220 --> 01:34.890
is array itself which returns.

01:34.890 --> 01:35.490
And right.

01:38.220 --> 01:44.910
This is the general structure of foreach method, but commonly it's used with only first parameter,

01:44.910 --> 01:46.750
which refers to item of a right.

01:48.060 --> 01:50.730
But anyway, let's log it in council.

01:51.150 --> 01:51.510
Right.

01:51.510 --> 01:52.440
Cancel that log

01:55.200 --> 01:59.100
in order to avoid typing, cancel the logs for every parameter.

01:59.100 --> 02:03.330
We can just separate them by commas and use only one.

02:03.330 --> 02:04.140
Cancel that log.

02:04.140 --> 02:09.390
So right here inside the parentheses icon, that index and.

02:10.590 --> 02:10.920
Right.

02:14.470 --> 02:22.420
Reload the page and you see that we have an error, which we have already seen previously, and it's

02:22.750 --> 02:28.240
definitely clear why we have just got it far, which is an array method.

02:28.720 --> 02:30.360
It works with a race.

02:30.370 --> 02:33.590
And in this case, Aitken's is just a collection.

02:34.840 --> 02:40.240
So in order to use forage for icons, we need to transform it into a right.

02:41.020 --> 02:47.090
And for that we can use a red dot from method, which we have already seen previously.

02:47.650 --> 02:56.140
So right away that from and inside parentheses plus icons.

03:00.270 --> 03:07.770
Then reload, and here we have results where you can find three parameters, which we have passed inside

03:07.770 --> 03:08.310
a function.

03:09.000 --> 03:17.580
First one, we have an item or current element, then the index number and write itself.

03:20.680 --> 03:28.090
So it proves that function was executed according to the number of items, we had six items and therefore

03:28.090 --> 03:34.320
function was executed six times in order to see it better.

03:34.360 --> 03:44.100
That leave just one parameter icon, then reload and we have six items of an array.

03:45.760 --> 03:52.570
OK, let's move on and talk about another dumb method, which I like at elements by class name method

03:52.570 --> 03:56.940
is used to get and manipulate on multiple HDMI elements.

03:57.670 --> 04:00.510
I'm talking about get elements by Takanabe method.

04:01.840 --> 04:08.920
This method returns a collection of all elements in the document with the specified target name as an

04:08.920 --> 04:10.030
e-mail collection.

04:11.920 --> 04:19.190
All right, let's go back to Brackett's and get rid of these codes because I don't need them anymore.

04:20.050 --> 04:22.000
Let's get access on these elements.

04:22.000 --> 04:33.520
So create variable ice and use get elements by TAKANABE Method write document that get elements by Tognum

04:35.290 --> 04:43.840
and inside the parentheses indicate the taqaddum of least elements so right élite then log it in council.

04:43.840 --> 04:44.110
Right.

04:44.110 --> 04:47.530
Cancel that log Ellyse.

04:50.630 --> 05:02.150
Reload and here we have all these elements, if we drop down it, you will see that it's again an e-mail

05:02.150 --> 05:02.770
collection.

05:03.620 --> 05:08.350
The result is an exact similar as it was in case of get elements by class method.

05:10.280 --> 05:14.510
So I'm not going to waste time on that because I think it will be boring for you.

05:15.110 --> 05:22.190
I just want to say that these two methods get along by class name and get elements by tag name work

05:22.190 --> 05:23.390
in the exact same way.

05:23.870 --> 05:30.050
The main difference is that you get elements by class name select elements with specified class name

05:30.440 --> 05:35.300
and get elements by tag, name, select elements using specified techniques.

05:36.380 --> 05:37.850
All right, that's it.

05:38.690 --> 05:39.950
See you in the next video.
