Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

224
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda