Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
querySelectorAll doesn't find element in Woocommerce single product page

Trying to work with single product gallery navigation. This is Woocommerce website.

product gallery navigation

Here is HTML code of this area:

enter image description here

I'm sorry, but I can't copy it from page source, because there is no such piece of code. I am trying to get ol.flex-control-nav element using this code:

console.log('ok');
let addImagesLength = document.querySelectorAll('.woocommerce-product-gallery ol');
console.log(addImagesLength);

Using "ok" in console log to be sure, that code is correct before it. So everything what I get in log is empty node list. I assume, that ol.flex-control-nav element is appearing after .js file loads. One thing what also I would like to mention is that product gallery navigation section is called in wwocommerce.php page using this snippet:

function web_add_woocommerce_support() {
    add_theme_support( 'woocommerce' );
}
add_theme_support( 'wc-product-gallery-slider' );
add_action( 'after_setup_theme', 'web_add_woocommerce_support' );

So I assume, that this piece of code loads gallery navigation after .js file was fully loaded. Was trying to enqueue separate .js file after this PHP code, but result is the same. If it is so, then how can I solve this problem?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Solved this problem by adding putting all function into window.onload.

window.onload = function () {
    console.log('ok');
    let addImagesLength = document.querySelectorAll('.flex-control-nav');
    console.log(addImagesLength);
}

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda