1
00:00:02,290 --> 00:00:04,870
Now being able to add elements is of course nice,

2
00:00:04,870 --> 00:00:06,790
sometimes you also want to remove them.

3
00:00:06,880 --> 00:00:09,870
Now with replace with, we are able to remove them

4
00:00:09,880 --> 00:00:15,910
but of course only to replace an element with a brand new one. To just get rid of it,

5
00:00:15,910 --> 00:00:23,930
we of course also have ways. Now for that, I reloaded this document and here, let's say we want to get rid of

6
00:00:23,930 --> 00:00:24,910
that entire list.

7
00:00:24,910 --> 00:00:31,410
So I'll again select it with document query selector ul, ul as a string

8
00:00:31,630 --> 00:00:34,150
and now to get rid of it, there are two ways.

9
00:00:34,210 --> 00:00:38,640
One is to use list.remove

10
00:00:39,070 --> 00:00:41,180
and this will just do what it sounds like,

11
00:00:41,200 --> 00:00:44,210
it removes the list from the DOM,

12
00:00:44,230 --> 00:00:48,870
so from the rendered page. Now good old MDN,

13
00:00:48,890 --> 00:00:55,370
if we check the remove method there shows us however that Internet Explorer again is not too fond of

14
00:00:55,370 --> 00:00:55,940
this method

15
00:00:55,940 --> 00:01:01,610
so if you want to ensure that this works there as well, you can't really use remove there. All other

16
00:01:01,610 --> 00:01:04,700
browsers have great support so you can definitely use it there

17
00:01:04,820 --> 00:01:11,480
but if you need to support this like this in Internet Explorer, then another way of making this work is

18
00:01:11,480 --> 00:01:17,640
to select the item you want to delete and then you reach out to the parent element,

19
00:01:17,810 --> 00:01:24,590
so the element node above the item you want to delete and there you have a remove child method and to

20
00:01:24,590 --> 00:01:30,770
that, you pass the item which you want to delete, list in this case and it will also work. Remove child

21
00:01:30,770 --> 00:01:36,320
is supported in all browsers, just like append child and therefore, this is the safest way of removing

22
00:01:36,320 --> 00:01:42,230
an element, reaching out to its parent and then remove child and then passing the item you want to remove

23
00:01:42,650 --> 00:01:45,000
but again, remove also has pretty good support.

24
00:01:45,080 --> 00:01:50,330
If Internet Explorer support doesn't matter for you, then just remove on the item you want to remove

25
00:01:50,660 --> 00:01:53,900
just like this is of course the shorter and the recommended way.
