Automatic click every 10 seconds

0

I have a carousel on the site, and I want it to run every ten seconds, as if the visitor has clicked the button to do this.

This is the site link

Here's all the plugin JS (WP Carousel Posts) link

And here, the inclusion I made in this JS

window.setTimeout(function(){
   document.getElementsByClassName("owl-dot").click();
}, 10000);

It is not working. I wonder why.

    
asked by anonymous 25.05.2016 / 02:46

2 answers

4

One suggestion: It might be cool to take a look at the Bootstrap carousel if you do not know: Carousel with Bootstrap

Well, but if you need this way the operation of the site, you can do the following:

var runCarousel = function (carousel, index, timeout) {
    window.setTimeout(function(){
    carousel[index].click();
    }, index*timeout);
}

This function will cause the selected carousel to "rotate" the carousel with the timeout you want.

An example of using the function would look like this:

var carousel = document.getElementsByClassName("owl-dot");

for (var i = 0; i < carousel.length; i++) {
    runCarousel(carousel, i, 2000)
}

This will cause the carousel (with owl-dot class buttons) to rotate every 2 seconds!

I hope I have helped,

Giulio ~

    
25.05.2016 / 04:55
0

I've been taking a look at the site. If you're working on the photo show on the home page:

jquery:

var slideNum = 0;
setInterval(function() {
   jQuery('a.nivo-control').removeClass('active');
   jQuery('a.nivo-control[rel="' +slideNum+ '"]').click();
   jQuery('a.nivo-control[rel="' +slideNum+ '"]').addClass('active');
   slideNum += 1;
   if(slideNum >= jQuery('a.nivo-control').length) {
       slideNum = 0;
   }
}, 10000);
    
25.05.2016 / 16:21