Trying to work with single product gallery navigation. This is Woocommerce website.
Here is HTML code of this area:
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?
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);
}