Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!