Learn JavaScript DOM Traversal In 15 Minutes

Поділитися
Вставка
  • Опубліковано 1 гру 2024

КОМЕНТАРІ • 295

  • @Soap_js
    @Soap_js 3 роки тому +65

    00:00​ - Intro
    01:34​ - getElementById
    03:04​ - getElementsByClassName
    04:16​ - QuerySelector
    06:48​ - querySelectorAll
    07:50​ - Selecting Children
    09:19​ - Selecting Descendants
    10:39​ - Selecting Parents
    12:00​ - Selecting Ancestors
    13:15​ - nextElementSibling
    13:51​ - previousElementSibling

  • @mznunaya
    @mznunaya 4 роки тому +13

    I JUST got done telling my bootcamp instructor how I need to review the DOM. And then I open my phone and see a notification for this video. Got dammit Kyle you've done it again. 👏

  • @roey6541
    @roey6541 4 роки тому +49

    Such a pleasure watching you explain! These concepts can be tough but you're very assuring and confident. I rightaway went to check out your js course, and purchased it immediately. Looking forward on starting! Feels like the first day of school :)

  • @xenialxerous2441
    @xenialxerous2441 4 роки тому +29

    Hi!! I just wanted to say, that your channel and your videos are true to their perfection. As the name goes so as the content 🤗 Love you bro, your efforts are forever appreciated!!

  • @mateonavarrette4864
    @mateonavarrette4864 3 роки тому +8

    Great rundown! I never really solidified my DOM traversal skills in my coding bootcamp, we just touched on a bit of vanilla js then jumped into react. Thanks for clearing some of my confusion up

  • @Ayomikun
    @Ayomikun 4 роки тому +15

    I just realised that I've learnt soo much JavaScript / React from you, it's ridiculous. Thank you!

  • @neelamchaubey28
    @neelamchaubey28 4 роки тому +7

    Thanks so much for explaining the most powerful DOM Traversal methods in such an easy way, Kyle!
    Keep up the good work👍

  • @revizion9101
    @revizion9101 Рік тому +2

    Great video ive been struggling so much with this concept as ive been using the odin project and in their js course they keep linking to articles that provide examples for all the basics of js but they use these damn selectors and DOM manipulation in their examples which has made learning js 100x harder than its needed to be so this video is a huge help

    • @toluwanimiayodele1858
      @toluwanimiayodele1858 11 місяців тому

      Brooo, I’m in the same situation, I love the Odin project but Mann these damn dom manipulation. How is it going now for you?

  • @Adam-iq6zn
    @Adam-iq6zn 4 роки тому +3

    I work as Front-end Dev for 2 years now (small and medium software companies), and I didn't know about closest, nextElementSibling and previousElementSibling methods at all 😲
    Usually I write my own functions to find specific parent or sibling.
    Thanks for enlighten me about this xD

  • @randymartin9040
    @randymartin9040 2 місяці тому

    Great video, Dom traversal has been pretty difficult for me to figure out, this helped a lot. Thank you

  • @cacup7
    @cacup7 4 роки тому

    The best traversal class. You rock on teaching and you are proving for each video that you are simplifying the web for everybody. Congratulations, man

  • @ohhellothere1111
    @ohhellothere1111 4 роки тому +9

    Havent used query selectors on anything other than document and first time seeing closest() method aswell. Good vid thanks dude :)

    • @bentoth4324
      @bentoth4324 4 роки тому +1

      closest() is crucial, especially when dealing with events. (almost) never go up with a while loop

  • @pkorneev5226
    @pkorneev5226 Рік тому

    super super useful. Noone actualy talk much about dom traversal, but this is the most important thing when you learning JS. I had soooo much problems with that cos i know some programming in other languages and have ideas how to do smth in js, but i cannot simply connect my code to my html+css page, now it looks super easy.

  • @tdematos
    @tdematos Рік тому

    One of the best videos that I have seen for traversing the DOM. It's extremely easy to understand to the point, and very clear on what each action does!

  • @IELTSMANTRA-wy1rl
    @IELTSMANTRA-wy1rl Рік тому

    You are literally the best teacher with clear explanations .. totally awesome content .. thank u so so much ..

  • @SocksWithSandals
    @SocksWithSandals 4 роки тому +121

    This is great for jQuery dinosaurs like myself who are moving to ES6.

  • @lingtravis6325
    @lingtravis6325 Рік тому

    The tutorial is super useful and easy to understand. And it solve the problem that bothered me for 2 days . Thank you so much

  • @alfredolino8203
    @alfredolino8203 4 роки тому +54

    I always learn a new thing from you, no matter what. Greetings from México.

    • @TheinfinityLight
      @TheinfinityLight 4 роки тому +1

      Epaaa otro Mexicano aprendiendo, muy buena. Saludos paisa

    • @alfredolino8203
      @alfredolino8203 4 роки тому +2

      @@TheinfinityLight Saludos compa

    • @bk._550
      @bk._550 4 роки тому +1

      @@alfredolino8203 hola

    • @cmnweb
      @cmnweb 4 роки тому +1

      Que pedo....

    • @TheinfinityLight
      @TheinfinityLight 4 роки тому +1

      @@cmnweb Qué pedo banda! ✌️

  • @stevenleonmusic
    @stevenleonmusic 3 роки тому +1

    One thing you can't easily do with Vanilla JS even in 2021 is search for siblings that match a selector. I use this on our website because we have togglers that affect sibling elements below them on the page and sometimes they have descriptions in between or images so we can't reasonably just use nextElementSibling since it may not be the very next one. You can do this easily with recursion.
    If you need full up/down capabilities:
    const findSibling = (element, selector, direction) => {
    if(!element) return null;
    direction = direction || "down";
    let methods = {
    up: "previous",
    down: "next"
    };
    let next = element[`${methods[direction]}ElementSibling`];
    if (next?.matches?.(selector)) return next;
    return findSibling(next, selector);
    };
    If you just want to search down the tree (and never up):
    const findNextSibling = (element, selector) => {
    if(!element) return null;
    let next = element.nextElementSibling;
    if (next?.matches?.(selector)) return next;
    return findSibling(next, selector);
    };
    There's no real fear of infinite recursion since next/previous ElementSibling will eventually return null.

  • @francisugorji5639
    @francisugorji5639 2 роки тому

    Thank you for simplifying JavaScript. I always learn new stuffs when I watch your videos

  • @Guii0
    @Guii0 2 роки тому +1

    You're very good at explained things, it show us that it's not as difficult as we thought, actually it's really simple.

  • @Dameworth
    @Dameworth 3 роки тому +1

    You’re a natural teacher, thanks for all the videos!

  • @jomesias
    @jomesias 4 роки тому +4

    Cool tutorial! This is exactly what moustache binding replaces, so no more direct DOM calls (of course react ref can always be used for specific scenarios ). Though dom tree navigation is still needed for certain applications, js frameworks are phasing this out. For better or worse👍👍👍
    Btw THAT IS A KILLER LOOKING JACKSON GUITAR IN THE BACK! Loving it 🎸 🎸 rock on. 0:01

  • @devt.9712
    @devt.9712 3 роки тому

    Dude you are amazing.Thanks for making that Frontend/Backend guide, it's so easy to follow and makes my learning process a lot easier. Love you!

  • @jeremyptlt
    @jeremyptlt 2 роки тому +1

    These explanations are so clean, congrats on that!

  • @thelostvorg7805
    @thelostvorg7805 3 роки тому

    I checked the Timestamps and I was like meh I know all of these but I watched the video anyway because you never know what you will find and then you mentiond the closest() function which I never knew existed ! I'm glad I stayed till the end of the video!

  • @NecquiTeja
    @NecquiTeja 4 роки тому +7

    Thank you... appreciate your efforts in making these videos. Keep it up my friend.

  • @naveen7513
    @naveen7513 2 роки тому

    I am following your front end development road map as the stepping stone for my career bro. Seriously they way u explain is great and i think by following ur tutorial i can be placed in MNC or other web development firm sooner. But few things I can’t understand quickly it doesn’t mean ur teachings are not good it’s just me who is slow at the moment. But i am trying to push my limit to the end to grab the knowledge of how programming works. Thanks man!❣️🙏🏻

  • @alinademi
    @alinademi 4 роки тому +1

    It really did simplify the most important parts of the DOM traversal. Awesome job!

  • @amiraalabeedi541
    @amiraalabeedi541 10 місяців тому

    Thank you. Iv watched several videos of js and css in this channel. Very very useful.

  • @pabhay235
    @pabhay235 3 роки тому

    too good with very simple examples. it cleared my concepts in 14 minutes sharp.... much appreciated

  • @mustafeezahmed9536
    @mustafeezahmed9536 3 роки тому +1

    Hey Kyle, your videos literally blown my mind. So much knowledge with so ease. Thanks a Lot buddy!

  • @coolcha
    @coolcha 4 роки тому +3

    Very good video and I appreciate the timestamps as I knew some but I could skip to those which were new to me.

  • @makiaboabida
    @makiaboabida 3 роки тому +1

    This is amazing man. Thank you for making this video!

  • @guchierrez
    @guchierrez Рік тому

    great guide, literally the best material online for learning DOM

  • @啾啾啾-k2t
    @啾啾啾-k2t Рік тому

    just start learning web dep, absolutely love all your videos, thank you for making and sharing those ❤

  • @TheCodingOdyssey
    @TheCodingOdyssey 4 роки тому +2

    This was interesting to me. I am a self-taught developer, but mostly worked pretty extensively with React in my job so not much vanilla javascript dom manipulation which I am looking to learn more.

  • @Zachariah_Pini
    @Zachariah_Pini 3 роки тому

    Subbed, watched full vid and clicked the bell icon. Thanks dude you are the G.O.A.T!

  • @ThiagoVieira91
    @ThiagoVieira91 4 роки тому

    Had to deal with these this week. This video would help a lot. Thank you Kyle! 👍🏼

  • @ShinAkuma
    @ShinAkuma 4 роки тому +1

    The only time I ever touch jQuery is when I need to traverse the DOM and now I don't need it at all.
    Thanks a lot.

  • @natalisulcer974
    @natalisulcer974 Рік тому

    Thank you so much !!!! One of the best videos!!!!

  • @dhawalparmar7117
    @dhawalparmar7117 3 роки тому

    Bro it is best youtube channel for javascript tips and tricks....Please make tutorial on angular react and vue

  • @stefanmitrovic7680
    @stefanmitrovic7680 2 роки тому +1

    I only watch your videos about website programming.This only says how good you are at explaining code and most importantly is easy to understand and also to memorize. 🤗

    • @UFO_808
      @UFO_808 Рік тому

      Ja ga i ne gotivim bas, prica monotono previse, kao da slusam robota

  • @focusme-tv3650
    @focusme-tv3650 3 роки тому

    Hi ! Just wanted to check if I knew everything about traversing, so classic check up. I do, but god your video was just extremly clear and pleasant to listen to. I subscribed ! =D
    By the way, for the beginners, the main difference between "parentElement" and "parentNode" methods is that the first one returns an HTML collection, which is kind of an array storing ONLY elements, while the second returns a nodeList, which returns all the parent nodes. Nodes can contain elements but also text / comment etc. ... So it's not a weird behavior but more a very specific method that we, as web developers, need to take in consideration.

  • @webartem
    @webartem 4 роки тому

    I like the way you explain it so much! even gonna forgive you missed semicolons and different quotation marks

  • @Gerry090
    @Gerry090 4 роки тому +9

    For those who are on the fence about his JS course, I suggest you buy it. I'm following his course and I can tell you that Kyle is a great teacher!

  • @pedrohenriqueduartebueno6873
    @pedrohenriqueduartebueno6873 4 роки тому +7

    Your explanation is pretty good, 👍🏻👍🏻👍🏻

  • @_Jordo
    @_Jordo 4 роки тому +3

    I thought I knew all this but watched just in case. You taught me that closest goes upward. Thanks!
    PS. I am curious to see how you look without your hair styled haha

  • @MbahmukongDestiny-up3tv
    @MbahmukongDestiny-up3tv 8 місяців тому

    Your methods are fascinating thanks alot🎉

  • @carltongordon
    @carltongordon 4 роки тому +1

    9:50 is such a shocker I had no idea thanks yo!

  • @AlThePal78
    @AlThePal78 2 роки тому

    I am so glad I am in your discord. Someone just saved my life lol or helped me with this. I also love your CSS Battles. You should do that with JS to see how you both differ in your writing functions, that would be awesome to see.

  • @AndreaDAuria1
    @AndreaDAuria1 3 місяці тому

    This video is a treasure, thank you so much❤❤

  • @alexzhang9031
    @alexzhang9031 2 роки тому

    Absolutly amazing video!

  • @kidgamer4787
    @kidgamer4787 3 роки тому

    you are too good to describe for words!!!!!

  • @espiritualidadedesvendada
    @espiritualidadedesvendada 3 роки тому

    It really helped me... Thank you very much !!!!

  • @russellabraham9208
    @russellabraham9208 4 роки тому

    Happy to see this video. I think you could have mentioned a few more details for a more rounded look at scope with querySelector. Also you can traverse in a chain with closest().querySelector().closest().querySelector().closest().

  • @shahidshafi1227
    @shahidshafi1227 2 роки тому

    You Just made DOM easy for me ❤️. Thanks a lot .

  • @joanclarke2724
    @joanclarke2724 4 роки тому

    Great tutorial. I have learnt so much from it. Thanks Kyle

  • @zhumabayevorymbek2548
    @zhumabayevorymbek2548 7 місяців тому

    Brilliant!) Explained many things for me)

  • @HolisticPython
    @HolisticPython 4 роки тому

    Thanks for all the free tutorials. Wondering if you could do a video on just general coding fatigue and any tips on how to remedy it?

  • @MrDflego
    @MrDflego 4 роки тому

    I got a whole lotta love for this video.

  • @digigoliath
    @digigoliath 4 роки тому

    Awesome!! Well explained & easy to follow!

  • @LanguageSkillz
    @LanguageSkillz 3 роки тому

    9:09 makes me have to clarify traversing along parent children across parent siblings. It comes up a lot with some layouts. Kudos with distinguishing closest for ancestors, and I appreciate how you go about familiarizing usage of techniques like detailing .children properties on a variable and converting with Array.from to establish an array simple to handle with .forEach. Built-in properties of ES6.

  • @Pareshbpatel
    @Pareshbpatel 3 роки тому

    A very fluent and comprehensive tutorial on DOM Traversal. Thank you very much.
    {2016-06-25}

  • @passandscore_
    @passandscore_ 3 роки тому

    Another great video!!

  • @chickendev5759
    @chickendev5759 3 роки тому

    concise and easy to understand

  • @fawwazhosein
    @fawwazhosein 4 роки тому

    Great revision. Thanks man!

  • @saidibrahim5931
    @saidibrahim5931 4 роки тому

    wow your teaching skill is amazing

  • @sacrajah
    @sacrajah 3 роки тому

    Thank you , Kyle . I learnt something today.

  • @Rohan-bg8ci
    @Rohan-bg8ci 4 роки тому +2

    Thanks for revision!!!

  • @danielbark
    @danielbark 4 роки тому

    Thanks Kyle! Great stuff in this one!

  • @karthikhs2530
    @karthikhs2530 2 роки тому

    beautiful way of explanation

  • @mark-y
    @mark-y 4 роки тому +1

    Nice video, but one mistake (9:31) - you can apply getElementById selector only for document element

    • @WebDevSimplified
      @WebDevSimplified  4 роки тому +1

      Good catch!

    • @StephenHind
      @StephenHind 4 роки тому

      At multiple points in the video you use the children selector sometimes prefixing with Array.from and sometimes without: I'm guessing the Array.from isn't necessary as you directly access the children using forEach without Aaray.from?

    • @sebastiansimon7557
      @sebastiansimon7557 4 роки тому +1

      @@StephenHind No, there’s a difference between `HTMLCollection`s as returned by `getElementsByClassName` and `NodeList`s as returned by `querySelectorAll`: the latter has a `forEach` method, whereas the prior doesn’t.

  • @mitch1668
    @mitch1668 2 роки тому

    Excellent explaining.

  • @ntnurobert218
    @ntnurobert218 4 роки тому +1

    Great ! I learned “closest”. Thank you

  • @anubhavrauniyar3192
    @anubhavrauniyar3192 Рік тому

    Thanks Thanks Thanks , Great Tutorial

  • @guptarishav50
    @guptarishav50 3 роки тому

    Great Vid. Thank You!!

  • @AcheiversOfficial
    @AcheiversOfficial 3 роки тому

    very helpful. May the force be with you. 👍.

  • @aresfrt
    @aresfrt 4 роки тому

    Great teacher, great job

  • @funkykong9001
    @funkykong9001 4 роки тому

    AMAZING! Thanks!

  • @pedrocxbx
    @pedrocxbx 3 роки тому

    Amazing, thanks Kyle!

  • @sashatv138
    @sashatv138 4 роки тому

    Super! Thank you, Kyle!

  • @FirdavsiGameDev
    @FirdavsiGameDev 4 роки тому

    Great tutorial, man!

  • @shubhamrathod9249
    @shubhamrathod9249 8 місяців тому

    now i understand dom! thank you

  • @ashse4424
    @ashse4424 4 роки тому

    Superb Brother, Thank you so much.

  • @adnanahad
    @adnanahad 3 роки тому +2

    Every want to watch full code...
    Its confusing 😭 i.e html and css full code...please

  • @giovannielias8153
    @giovannielias8153 Місяць тому

    you could select the next child with document.querySelector("#child-one +")
    Remember that in a query selector you use CSS selectors, and with the new CSS stuff like :has, :is, :not
    And each CSS update, querySelector is more useful

  • @sporthistorystat
    @sporthistorystat 4 роки тому

    thank you bro. love from Türkiye

  • @bernardoeulermusic
    @bernardoeulermusic 2 роки тому

    mannn, thanks a lot for showing this method Array from, i was struggling with HTML Collections

  • @skaywalker20
    @skaywalker20 4 роки тому

    Very helpful stuff, thank you so much!

  • @dovinhas
    @dovinhas 3 роки тому

    simplified that's the word thanks from Africa Angola

  • @pawejakubowski829
    @pawejakubowski829 3 роки тому +1

    Led Zeppeling shirt! Props!

  • @skylerjknight
    @skylerjknight 4 роки тому

    Nice simple tutorial. Thanks.

  • @dariusz8005
    @dariusz8005 2 роки тому

    Thanks ! You are helped me too !! :)

  • @rgablejr
    @rgablejr 4 роки тому

    Great examples!

  • @rinkeshgokulchandani4181
    @rinkeshgokulchandani4181 4 роки тому

    Good Content, learned some new things!

  • @theMagos
    @theMagos 2 роки тому +1

    Note that closest() starts by checking itself, not its parent. This may (or may not) make a difference.

  • @codeandcurious
    @codeandcurious 3 роки тому

    Thank you so much for the video

  • @hellyski
    @hellyski 4 роки тому

    Great video! Thank you.

  • @abhishekbevinal7495
    @abhishekbevinal7495 3 роки тому

    thank u so much bro,,lv from india,,tq tq so much ,,