Learn JavaScript ELEMENT SELECTORS easy! 📑

  Рет қаралды 36,063

Bro Code

Bro Code

Күн бұрын

Пікірлер: 39
@BroCodez
@BroCodez Жыл бұрын
// element selectors = Methods used to target and manipulate HTML elements // They allow you to select one or multiple HTML elements // from the DOM (Document Object Model) // 1. document.getElementById() // ELEMENT OR NULL // 2. document.getElementsClassName() // HTML COLLECTION // 3. document.getElementsByTagName() // HTML COLLECTION // 4. document.querySelector() // FIRST ELEMENT OR NULL // 5. document.querySelectorAll() // NODELIST // ---------- getElementById() ---------- const myHeading = document.getElementById("my-heading"); myHeading.style.backgroundColor = "yellow"; myHeading.style.textAlign = "center"; // ---------- getElementsByClassName() ---------- const fruits = document.getElementsByClassName("fruits"); Array.from(fruits).forEach(fruit => { fruit.style.backgroundColor = "yellow"; }); // ---------- getElementsByTagName() ---------- const h4Elements = document.getElementsByTagName("h4"); const liElements = document.getElementsByTagName("li"); Array.from(h4Elements).forEach(h4Element => { h4Element.style.backgroundColor = "yellow"; }); Array.from(liElements).forEach(liElement => { liElement.style.backgroundColor = "lightgreen"; }); // ---------- querySelector() ---------- const element = document.querySelector("li"); element.style.backgroundColor = "yellow"; // ---------- querySelectorAll() ---------- const foods = document.querySelectorAll("li"); foods.forEach(food => { food.style.backgroundColor = "yellow" });
@alecrestorick
@alecrestorick 3 ай бұрын
Honestly the way you teach is extremely effective and enjoyable and you make it easy to follow as you explain. You explain everything so clearly and make it easy to understand the why's and how's and understanding is half the problem with coding. Your ability to teach is top quality for leaners, I actually enjoy listening to you and following along with your videos for several hours a day. Many other channels are just boring and yours is the opposite. Im sure you had a masterful teacher who imparted a masterful approach to learning and teaching on yourself. I look forward to following all your various code language tutorials. Thank you for doing what you do.
@PurplexSKyo
@PurplexSKyo Жыл бұрын
Hello Bro Code I love your videos, I try to learn C by looking your videos and its amazing I know its a litter bit late for tell you this but can you please do a tutorial learn Lua please if its don't mind you Thanks you for having the time to look the lines and keep continute I love your videos👍🏾👍🏾
@Salainganba-v6i
@Salainganba-v6i Ай бұрын
The best fullstack teacher
@INSIGHT16
@INSIGHT16 Ай бұрын
This video is underrated
@Debelinka
@Debelinka 11 ай бұрын
What a G! Thanks legend!
@asitonph
@asitonph 2 ай бұрын
Well explained, thank you!
@martinmurithi2076
@martinmurithi2076 9 ай бұрын
BEST ON THIS TOPIC SOO FAR
@bruhboing3349
@bruhboing3349 11 ай бұрын
loved your video, thanks for the explanation :)
@ruquiaalam5546
@ruquiaalam5546 5 ай бұрын
Thanks a ton!!! amazing tutorials
@Hellisfear
@Hellisfear 4 ай бұрын
This was super super useful. Thanks
@Daniel-copypaste
@Daniel-copypaste 8 ай бұрын
really appreciate it bro , you made it easy for me thank you
@WebDevelop-w8x
@WebDevelop-w8x 2 ай бұрын
great explaining, some YT toturials got this whole wrong, good job.
@ENDTIM3SPRODUCTIONS
@ENDTIM3SPRODUCTIONS Жыл бұрын
Do a Lua full course please!!!!!
@amirrezaabbasi-k6p
@amirrezaabbasi-k6p 4 ай бұрын
that was so good ! ty
@A_curious_chicken
@A_curious_chicken 7 ай бұрын
Great
@levon9
@levon9 8 ай бұрын
Very nice explanation. Could you elaborate a bit more on the difference between HTML collections and node lists? What does it mean that they (node lists) don't update? Thanks!
@theideadude
@theideadude 3 ай бұрын
excellent vid but onions are root vegetables!
@AmjadGD
@AmjadGD Жыл бұрын
At 6:49 I think we could also do fruits[0, 1, 2].style.backgroundColor = "yellow"; I suppose?
@hunin27
@hunin27 Жыл бұрын
if you want to do like this you would need to iterate over every element inside of the array and change the background color
@uddipta03
@uddipta03 11 ай бұрын
in this approach it will only change style to the last ement only
@MikeZane111
@MikeZane111 11 ай бұрын
lets goooooo
@mohamedshinaishin2822
@mohamedshinaishin2822 9 ай бұрын
Bro you are terribly awesome , It's so sad we won't see you again
@levon9
@levon9 8 ай бұрын
What does that mean? He quit making videos?
@mohamedshinaishin2822
@mohamedshinaishin2822 8 ай бұрын
@@levon9 he did say so in one of his latest videos
@levon9
@levon9 8 ай бұрын
@@mohamedshinaishin2822 thanks, I must have missed it. Too bad, he's good. 👍
@mohamedshinaishin2822
@mohamedshinaishin2822 8 ай бұрын
@@levon9 yeah but he left a ton of videos for us to enjoy
@panaskw
@panaskw 7 ай бұрын
he's still posting videos pretty much daily what do you mean
@xzex2609
@xzex2609 Жыл бұрын
still doesn't understand if the object that getElementsByClassName returns is not iterable how it is that you use for on that collection thing
@amandateixeira6143
@amandateixeira6143 11 ай бұрын
I’m still learning JavaScript but I think it’s because arrays have specific methods that don’t work with HTML collections (like forEach). But if you want to use the HTML collection in a for loop then it’s fine.
@KhureshiAbraam9999
@KhureshiAbraam9999 3 ай бұрын
No for inbuilt array methods it won't work for working we must typecast it to array. For Directly using inbuilt methods querySelectorAll is used
@PowerGumby
@PowerGumby 4 ай бұрын
what IDE is he using?
@spanxcode05
@spanxcode05 3 ай бұрын
VS Code
@xzex2609
@xzex2609 Жыл бұрын
😂😂😂😂 if I just watched the video instead of follow along I never had this much trouble to ask this question and solve it by my self I can not understand why this isn't working ? any help ? for(const [index , fruit] of fruits.entries()){ const color = ['blue', 'yellow', 'green']; fruit.style.backgroundColor = color[index] } how do I change the array like object that document.getElementsByClassName returns to an iterable Object ?? Answer : I searched and find that the collection is not an array and there is a method that can change it to an array ( amongst tons of other ways) for(let [index,value] of Array.from(fruits).entries()){ value.style.backgroundColor = color[index] }
@tee-hee9553
@tee-hee9553 Жыл бұрын
Me first ❤
@hamzagohar2048
@hamzagohar2048 6 ай бұрын
me 16,804 🥰🥰🥰🥰🥰🥰🥰
@manueldiegoalexander3879
@manueldiegoalexander3879 Жыл бұрын
where's the style ?
Learn DOM Navigation in 15 minutes! 🧭
15:27
Bro Code
Рет қаралды 19 М.
Learn DOM Manipulation In 18 Minutes
18:37
Web Dev Simplified
Рет қаралды 1 МЛН
진짜✅ 아님 가짜❌???
0:21
승비니 Seungbini
Рет қаралды 10 МЛН
What are JavaScript PROMISES? 🤞
12:37
Bro Code
Рет қаралды 94 М.
JavaScript FUNCTIONS are easy! 📞
12:14
Bro Code
Рет қаралды 56 М.
CSS Tutorial 2025  | 02 CSS Selectors
24:32
Destrie_Poetra
Рет қаралды 106
Learn the JavaScript classList property easy! 💡
16:00
Bro Code
Рет қаралды 14 М.
Learn JavaScript Event Listeners In 18 Minutes
18:03
Web Dev Simplified
Рет қаралды 611 М.
Learn JavaScript ARROW FUNCTIONS in 8 minutes! 🎯
8:02
Bro Code
Рет қаралды 51 М.
Build this JS calculator in 15 minutes! 🖩
15:20
Bro Code
Рет қаралды 778 М.
진짜✅ 아님 가짜❌???
0:21
승비니 Seungbini
Рет қаралды 10 МЛН