user1752759
user1752759

Reputation: 635

Delay/Pause Slick Slide Function

I'm trying to create a carousel on my website using slick.

On my website, I have a specific button which the user can select that will slide the carousel to the next section:

<button class="right-answer" onclick="showResult(this)">3</button>

This button uses the following line to make the transition:

function showResult(b) {
    if (b.classList.contains('right-answer')) {
        $(".qa").slick('slickNext')
    }
    else { ... }
}

This is similar to how the navigation arrows work in the slick demonstrations.

How can I make it so that when the user selects the button (which runs the code above), it will wait 5 seconds before executing?

Upvotes: 1

Views: 5620

Answers (1)

AmmarCSE
AmmarCSE

Reputation: 30557

Use setTimeout()

$('button').click(function() {
setTimeout(function() {
    $(".qa").slick('slickNext')
}, 5000);
});

Upvotes: 3

Related Questions