JavaScript: Elements by Tag name in DOM | getElementsByTagName | HTMLCollection #kody_az

preview_player
Показать описание

Əsas Xüsusiyyətlər:
1. HTMLCollection qaytarır:
getElementsByTagName()-in qaytardığı kolleksiya canlıdır və avtomatik yenilənir.

2. Teq Adlarında Hərf Böyüklüyü Həssaslığı (HTML üçün):
HTML sənədlərində teq adlarında hərf böyüklüyü nəzərə alınmır. Yəni getElementsByTagName("div") və getElementsByTagName("DIV") eyni nəticəni verəcək. Lakin XML sənədlərində (məsələn, XHTML, XML) teq adlarında hərf həssaslığı mövcuddur.

3. Global və ya Lokal İstifadə:

4. Nəticələrdə gəzinti (Iterasiya):
Qaytarılan HTMLCollection massivə bənzəsə də, o, bir massiv deyil. İterasiya üçün ənənəvi for döngəsindən və ya for...of döngəsindən istifadə edə bilərsiniz. Əgər massiv metodlarından (forEach, map, filter və s.) istifadə etmək istəyirsinizsə, onu əsl massivə çevirmək lazımdır.

========

Key Points about getElementsByTagName():
1. Returns an HTMLCollection:
Unlike methods like querySelectorAll(), which return a static NodeList, getElementsByTagName() returns a “live” collection. This means if the document structure changes after you call it (for example, if you add or remove elements), the returned collection will reflect those changes in real time.

2. Case-insensitivity in HTML documents:

3. Iterating Over the Result:
Because getElementsByTagName() returns an HTMLCollection, you can access elements by index or iterate through them, usually converting them into an array if needed, since HTMLCollection does not have array methods like forEach by default.

#kody_az #kodyaz #js #javascript #nodejs #es6 #viral #viralcode #nodejs #viralvideo #random #code #coder #azerbaycan #azerbaijan #baku #baki #programming #programmer #codes #hazırlıq #hazirliq #kurs #kurslar #course #courses #online #onlinecourses #test #quiz
Рекомендации по теме
join shbcf.ru