S
S
Sergey Volkov2021-06-24 16:01:05
JavaScript
Sergey Volkov, 2021-06-24 16:01:05

Why does the console output undefined when accessing htmlcollection?

Hello, the following problem arose:
With the help of getElementBeClassName I find a list with the class .goods-dots

const pagination1  = document.getElementsByClassName('goods-dots'); // Нахожу пагинацию


The console outputs this:
60d4810d2e459886369373.jpeg
60d48112bc8c8573553950.jpeg

I'm trying to access the first element, the console outputs this:
60d4817f62682501148366.jpeg

But querySelectorAll doesn't work at all:
60d481ba134c3897893410.jpeg

Link to the site -- lunamag-articles.malevich-web.ru/interview-cucu-be...
Here is the slider itself with pagination
60d48200ea8af236428671.jpeg

I will be very happy if you help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Volkov, 2021-06-24
@GovnoKoder_ITS

All this needs to be added to the event handler, which will display information after the page has loaded.

$(window).on('load', () => {

})

A
Alexander, 2021-06-24
@Seasle

document.querySelectorAll('.goods-dots');beautifully returns everything.
On account of , all getElementsBy* return HTMLCollections that are updated automatically when elements on the page change. document.getElementsByClassName('goods-dots');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question