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.
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! :)
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' }
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.
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
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.
What Kyle teaches: CSS styling
What I want to learn: Hair styling
😂
😁😁
He did it recently x)
@@DracoVoldre I saw 🙌
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.
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()
This was my pain, could not understand the weird behavior of the nodes and elements. Thank you very much, now I understand.
You just save my life.
I am working on a project and I need to understand this.
Thank you.
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!
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 RUclips to give you a like. Super helpful!!!! This cleared up a lot
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 are awesome brother. You clear all my doubt. Love from 🇮🇳
when someone incorrectly say "doubt" instead of "question" we know right away he/she is indian
Thank you so much, I was breaking my head trying to understand the differences between the nodes and the elements and how they work 🙃
Thank you for videos. Love from Turkey 🙂
Extremely helpful video ❤️
Thank you Kyle for giving this cheat sheet.Your teaching is also awesome 👌👌
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.
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! :)
Awesome! Well explained and simplified
Bro, I absolutely Love this video!
Kyle don't use any vscode theme but still he customizes it a lot which we cannot see directly !
Super well explained. thank you!
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?
Can't thank you enough for this! You really saved me from a couple of headaches lol
Thanks for this video and clear explanation.
Wow! AMAZING video Kyle!
Learned something new today, thank you!
thanks alot, kyle your tips and teachings are very informative and helpful.
Thank you very much Kyle for your detailed explanations.
I lost you at Element. Thanks for sharing
Shedding light on the dark corners 🙌
Awesome information, thanks for sharing
i had no idea about the live update thing. ty
Thank you Kyle, Thank you very much!
I always had doubts when it comes HTML node and element
Couldn't you easily convert either type of collection to arrays and not have to deal with live updates if that is not desired?
Thanks, that video helped a lot!
Great explainer, thank you Kyle.
This helped me soo much
That's a good point. thanks!
Thanks for all man
Great Video...learnt alot!
great video thanks a lot for your tip
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
Great content! thank bro
Can we get a collection of your cheat sheets Kyle? Pleeease!
I ask this my self a long time. Now i gonna figure it
Awesome Kyle thanks!
Please cover advance concepts of ES6 and ES7
but Kyle, why would we wanna have a static list that doesn't live-update ??
I think it's useful in filtering;
Learned something new!
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.
Great content
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 to reason for selecting because HTMLCollection its update automatically, When we selected sometime we don't want to update selecting further that we required.
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
Does this prevent live updates?
const parents = Object.freeze(document.getElementsByClassName('parent'))
oOo that's why you prefer querySelector instead of getElementsByClassName !
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! :)
Hlo sir I need ur help... how can I contact u?
super awesome
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.
Beast
wonderfull
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 😃