JavaScript Tutorial For Beginners #38 - Removing Elements from the DOM

JavaScript Tutorial For Beginners #38 - Removing Elements from the DOM

Net Ninja

9 лет назад

83,492 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@amirmekk9649
@amirmekk9649 - 09.06.2016 19:45

nice videos my friend you deserve more than millions of subs

Ответить
@BlueCrystal1996R
@BlueCrystal1996R - 22.02.2017 17:28

Dude your vids are awesome! Clear, clean, understandable, very good image/sound quality, easy... Just perfect! I know these vids are old but i had to say it! :)

Ответить
@sosorrymen
@sosorrymen - 23.08.2017 11:52

Are removed & child the same inside?

Ответить
@HH-yq3sy
@HH-yq3sy - 25.12.2017 00:56

VM1888:1 Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
at <anonymous>:1:18. I am getting that message when i try to removeChild or even to add new <li> on the top of <ul> . What am I doing wrong ?

Ответить
@kalpanasinghal5907
@kalpanasinghal5907 - 08.04.2018 20:24

what if i want to remove multiple div at the same time??

Ответить
@prashantpanwar8392
@prashantpanwar8392 - 16.04.2018 00:04

When we removed the 'subject' from 'Menu', it got replaced by one more 'course' ,
why is it so?

Ответить
@ashutoshpareek4875
@ashutoshpareek4875 - 08.05.2018 06:15

Var child =parent. getElementsByTagName("th") [0];
This statement gives error of parent. getElementsByTagName is not a function

Ответить
@HKNAGPAL7
@HKNAGPAL7 - 18.06.2018 10:20

It gets appended at bottom?

Ответить
@AllenZitting
@AllenZitting - 24.09.2018 21:11

Thanks! These videos are super helpful and clear.

Ответить
@SCIFIVAMPIRE
@SCIFIVAMPIRE - 18.11.2018 21:57

What is the benefit to doing this through Javascript instead of just removing in HTML document?

Ответить
@awadelkarim5639
@awadelkarim5639 - 11.12.2018 19:28

Keep going Ninja
All The best ;;;;;;

Ответить
@nowyouknow2249
@nowyouknow2249 - 28.12.2018 15:16

it can't be clearer than this.
Thanks a lot!!!

Ответить
@rajacasablanca9359
@rajacasablanca9359 - 30.01.2019 19:27

What about removing parent from a child?

Ответить
@ricardoforbes4008
@ricardoforbes4008 - 24.05.2019 03:06

i want you help with element i'm trying to delete

Ответить
@namhoang3755
@namhoang3755 - 27.07.2019 03:56

Thanks for you because help me Addressing my problem is difficult

Ответить
@TheSuperjam11
@TheSuperjam11 - 28.07.2019 09:06

if you want to remove all the code is =

var parent = document.getElementsByTagName("ul")[0];
parent.innerHTML = '';

Ответить
@0the0ambient0
@0the0ambient0 - 16.09.2019 06:05

Really useful explanation. Thx.

Ответить
@devilsdante
@devilsdante - 22.09.2019 23:09

An easier way to remove "child" would be only to do child.remove(). That will remove the element from the HTML. Don't really need to specify the parent :) Ofc using the parent.removeChild(...) is good for other more specific cases.

Ответить
@dreambusiness4379
@dreambusiness4379 - 08.12.2019 13:00

please what to do
the app that i have remove, the code still there and scroll dawn me site

Ответить
@shadowofzeus6267
@shadowofzeus6267 - 15.01.2020 11:17

@NetNija - I am loving your tutorials and learning all the way. I am a newbie so forgive me for me dumb question - I do not get why we would add or remove elements from JS instead of just doing it in HTML - wouldn't that be faster??

Ответить
@ajitsinghal9507
@ajitsinghal9507 - 24.01.2020 15:36

why we are using document.getElementById("main-nav") ???
why can't we direct use document.getElementsByTagName("ul")[0];

Ответить
@icebuds7455
@icebuds7455 - 10.05.2020 22:18

how do i remove a script? cause when i do it ona script and then (re)add it its says that its already declred

Ответить
@YouMaghReBieN12
@YouMaghReBieN12 - 06.11.2020 11:58

THANK YOU SO MUCH !!!

Ответить
@brunagobi7393
@brunagobi7393 - 20.11.2020 15:40

But If you dont know witch element Will be removed ? In case thate os a list and the user click to remove one of them

Ответить
@tjmarshLoL
@tjmarshLoL - 14.12.2020 22:31

Question: Could we use "Node.parentNode' instead of the longer document selector to define the parent? Thanks for video and response from anyone that can confirm my question above.

Ответить
@ritviksardana3893
@ritviksardana3893 - 21.01.2021 10:27

amazing content, but how to add a "href" in "a tag"??

Ответить
@najeebalishah9896
@najeebalishah9896 - 22.03.2021 19:29

what about multiple elements for example I want to remove the 'x' element and when I click on a button only that element should be deleted not others.

Ответить
@castroislivingonearth
@castroislivingonearth - 10.04.2021 03:06

I have to say... Thank You, bro!

Ответить
@touhidsourav2475
@touhidsourav2475 - 27.04.2021 16:27

How can I add style on that reome(). For say if I want it to be deleted with subtle animation how may I do it

Ответить
@ahmedabdallah8781
@ahmedabdallah8781 - 13.07.2021 10:58

i have this to do list and i have two buttons i wanna make one of the buttons removing the children of the <ul> so basically every time i press the button delete (addEventListener method) it should remove the children

Ответить
@akosv96
@akosv96 - 19.07.2021 14:53

"Remove the child"
This gives me Alex Jones vibes

Ответить
@mamajonovbegzod7848
@mamajonovbegzod7848 - 11.09.2021 17:45

O'zbeklar bormi

Ответить
@AnnedolfFrankler911
@AnnedolfFrankler911 - 17.01.2022 20:33

Love the vids, mate! Thank you!

Ответить
@gamerbeast5177
@gamerbeast5177 - 07.05.2022 06:21

There's a much simpler way to remove element and it just takes two steps.

var element = document.getElementsByTagName("li")[0];
element.remove();

Ответить
@SamAndDavo
@SamAndDavo - 26.06.2022 01:58

😊new subscriber!

Ответить
@kanycz2771
@kanycz2771 - 18.07.2022 21:11

I need to do this but from othere side i know the child but dont know in what parent it is. Love to hear some helpfull tips.

Ответить
@Rocksock531
@Rocksock531 - 25.10.2022 17:42

Legend

Ответить
@bagasraihansebastian10ipa34
@bagasraihansebastian10ipa34 - 11.12.2022 16:18

Wow 😱🤩

Ответить
@plutonio92
@plutonio92 - 08.03.2023 13:47

Amazing!! Thanks for these videos

Ответить
@ha_nguyen_146
@ha_nguyen_146 - 23.08.2023 07:11

thank you very much, very nice <33

Ответить
@fuyamoon
@fuyamoon - 14.10.2024 21:42

Very nice ! ThankYou!

Ответить