Why js does not see the elements of the carousel added to the page via Visual Composer (WPBakery)?

Hi all. I have a OWL carousel, adding it to the page I want to count number of items
jQuery(function($) {
 //(function() {
//alert();
 var testimonialsGalleryElement = $('.testimonials-gallery');
 var testimonialsGalleryOwlItemElements = $('.testimonials-gallery .owl-item');
 //var testimonialsGalleryOwlItemElements = testimonialsGalleryElement.find('.owl-item');
console.log(testimonialsGalleryOwlItemElements.length);
//})();
});


But, you know, the console always returns 0. But if I'm already in the console itself will prescribe these expressions, I get a number. What the problem like to be? To blame Visual Composer? My curves hands? WP? Thanks in advance
June 10th 19 at 14:58
1 answer
June 10th 19 at 15:00
Try to wrap the script can be considered when the carousel is still not displayed in the DOM
$( document ).ready(function() {

});
jQuery(function($) { this is equivalent to what you suggested, but shorter :) but just in case, and the full version I tried, the effect is the same - Kennedi_Thompson commented on June 10th 19 at 15:03

Find more questions by tags WordPressJavaScript