Tip to use Array methods on dom elements from document.querySelectorAll() 1) Array.from(document.querySelectorAll(“element”)) 2) […document.querySelectorAll(“.selector”)]
Super helpful! this was such a mystery to me. Though I see why direct DOM manipulation isn't exactly encouraged for beginners, this kind of operation could really use a framework to make it more maintainable and scalable!
Very informative. First time I noticed the difference between these DOM methods when I worked with , and nodes in a project. You have to notice that Node also is handling attributes and other DOM types. Therefore, the nodeType of a Node has these values: 1 (element), 2 (attribute), 3 (text) and more... Nine or ten in total currently.
you can use instanceof to see if a node is an HTML element. It makes working with nodes easier. ie. if (node instanceof HTMLElement) { node.innerText = 'this is an html element' }
Yup, can’t say how many times I’ve redefined the same query selector inside functions for dynamic content. Now I know I can keep just one definition in the global scope to get the updates.
Only you can demystify the most cryptic of JavaScript's intricacies in such an easily understandable manner within 9 minutes, Kyle! This was really helpful! :)
Before I watch… my guess is that nodes refer to anything while element refers to just tag based ones. Element would exclude text nodes and such Edit: despite my poor wording, I appear to be correct. Sweeeeeeet
Great to reason for selecting because HTMLCollection its update automatically, When we selected sometime we don't want to update selecting further that we required.
That was my question too, but I guess that in bigger projects you never know what sideeffects are triggered by calling some function. And let's say you are iteration through the "live updated list" with a for-loop and you are creating a const before that loop and store the list's length in there, then the iteration is faulty if some new element is added inbetween, because the for-loop won't reach the end of the array since it changed length. I guess it's not "bad practice" to use either, you just have to be knowing what you want to do, what things are happening inside your app and then decide for the best method :)
I have a request for a video. I do HTML, CSS and JS coding. For one of my projects, I require a custom scrollbar. I know how to make one, but the conventional ::-webkit scrollbars aren't as customizable as I'd like. What I'm looking for is to replace the scrollbar with a div, so that you have to drag the div to scroll, not the scrollbar thumb. Please help me, I haven't found a solution online yet.
One way would be to make the div draggable then use the ondrag event to calculate a position and scroll to it using window.scrollTo but it can be dragged both horizontally and vertically so you would have to lock it to only one.
This guy is born to be a teacher and mentor
The thing I like about Kyle's CSS tutorials is he always does it with style.
What Kyle teaches: CSS styling
What I want to learn: Hair styling
😂
😁😁
He did it recently x)
@@DracoVoldre I saw 🙌
Tip to use Array methods on dom elements from document.querySelectorAll()
1) Array.from(document.querySelectorAll(“element”))
2) […document.querySelectorAll(“.selector”)]
Thank you. Useful tips.
Thanks for this!
You are genious bro. Instead of focusing on just basic things you always dive deeper.
Also Nodelist can easily be converted into array with spread operator to be able to have all JavaScript array method functionality
Great tip brother.
I agree
Can we use Array.from()
You just save my life.
I am working on a project and I need to understand this.
Thank you.
This was my pain, could not understand the weird behavior of the nodes and elements. Thank you very much, now I understand.
You are awesome brother. You clear all my doubt. Love from 🇮🇳
Super helpful! this was such a mystery to me.
Though I see why direct DOM manipulation isn't exactly encouraged for beginners, this kind of operation could really use a framework to make it more maintainable and scalable!
I found this on your website and came to UA-cam to give you a like. Super helpful!!!! This cleared up a lot
Thank you so much, I was breaking my head trying to understand the differences between the nodes and the elements and how they work 🙃
Very informative. First time I noticed the difference between these DOM methods when I worked with , and nodes in a project.
You have to notice that Node also is handling attributes and other DOM types. Therefore, the nodeType of a Node has these values: 1 (element), 2 (attribute), 3 (text) and more... Nine or ten in total currently.
Kyle don't use any vscode theme but still he customizes it a lot which we cannot see directly !
you can use instanceof to see if a node is an HTML element. It makes working with nodes easier.
ie.
if (node instanceof HTMLElement) { node.innerText = 'this is an html element' }
I'm not sure how to set this up?
That info on live updates is really useful 🙂
Yup, can’t say how many times I’ve redefined the same query selector inside functions for dynamic content. Now I know I can keep just one definition in the global scope to get the updates.
Thank you Kyle for giving this cheat sheet.Your teaching is also awesome 👌👌
Extremely helpful video ❤️
Awesome! Well explained and simplified
Thank you for videos. Love from Turkey 🙂
Can't thank you enough for this! You really saved me from a couple of headaches lol
I lost you at Element. Thanks for sharing
Only you can demystify the most cryptic of JavaScript's intricacies in such an easily understandable manner within 9 minutes, Kyle! This was really helpful! :)
Bro, I absolutely Love this video!
Super well explained. thank you!
I always had doubts when it comes HTML node and element
Learned something new today, thank you!
Shedding light on the dark corners 🙌
Thanks for this video and clear explanation.
thanks alot, kyle your tips and teachings are very informative and helpful.
Wow! AMAZING video Kyle!
i had no idea about the live update thing. ty
Thank you very much Kyle for your detailed explanations.
Awesome information, thanks for sharing
Thank you Kyle, Thank you very much!
Thanks for all man
Thanks, that video helped a lot!
Couldn't you easily convert either type of collection to arrays and not have to deal with live updates if that is not desired?
This helped me soo much
Great explainer, thank you Kyle.
Can we get a collection of your cheat sheets Kyle? Pleeease!
I thought it's Node JS vs Someother New technology like Nodejs. 😂
Hahaha samee😂
me too
i immediately searched for element js XD
Me toooooo
I thought the same
Please cover advance concepts of ES6 and ES7
Before I watch… my guess is that nodes refer to anything while element refers to just tag based ones. Element would exclude text nodes and such
Edit: despite my poor wording, I appear to be correct. Sweeeeeeet
Great to reason for selecting because HTMLCollection its update automatically, When we selected sometime we don't want to update selecting further that we required.
Great Video...learnt alot!
Great content! thank bro
That's a good point. thanks!
Awesome Kyle thanks!
So a node is a superset of an element? Every element is a node but not every node is an element?
I think elements is a subset of a node.
I ask this my self a long time. Now i gonna figure it
great video thanks a lot for your tip
oOo that's why you prefer querySelector instead of getElementsByClassName !
Learned something new!
I've got four consecutive notifications this video, its like youtube trying to get an answer for you.
do you but do you?
Please do a tutorial on next js..
Great content
but Kyle, why would we wanna have a static list that doesn't live-update ??
I think it's useful in filtering;
Does this prevent live updates?
const parents = Object.freeze(document.getElementsByClassName('parent'))
super awesome
I didn't get it. Why would you prefer static over live update on HTML? I can't see any real case scenario where it would be harder to debug?
That was my question too, but I guess that in bigger projects you never know what sideeffects are triggered by calling some function. And let's say you are iteration through the "live updated list" with a for-loop and you are creating a const before that loop and store the list's length in there, then the iteration is faulty if some new element is added inbetween, because the for-loop won't reach the end of the array since it changed length.
I guess it's not "bad practice" to use either, you just have to be knowing what you want to do, what things are happening inside your app and then decide for the best method :)
@@mhombach3035 Sounds very reasonable! Great! Thanks for sharing! :)
Beast
wonderfull
I have a request for a video. I do HTML, CSS and JS coding. For one of my projects, I require a custom scrollbar. I know how to make one, but the conventional ::-webkit scrollbars aren't as customizable as I'd like. What I'm looking for is to replace the scrollbar with a div, so that you have to drag the div to scroll, not the scrollbar thumb. Please help me, I haven't found a solution online yet.
One way would be to make the div draggable then use the ondrag event to calculate a position and scroll to it using window.scrollTo but it can be dragged both horizontally and vertically so you would have to lock it to only one.
Hlo sir I need ur help... how can I contact u?
4th
I'm more inclined to listen to someone who plays a Jackson.
First comment , I know that's dumb but...😂
Your the 1st
That’s amazing 💪🏼
@@Arabian_Abomination thanks 😃