Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6096817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:58:17+00:00 2026-05-23T12:58:17+00:00

I built this function to scroll through a gallery. The gallery should scroll to

  • 0

I built this function to scroll through a gallery. The gallery should scroll to the next image by itself every 6000ms, but if the user clicks on a thumbnail it should go directly to that thumbnail and then reset the timer for 6000ms.

My code is not working because I do not think I got the JQuery retriggereing function right. Not quite sure what I am doing.

var timerp = null;

$('.thumbs').click(function() {
         clearTimeout(timerp);
         $('.cornerimgfocus').removeClass('cornerimgfocus');
         $('#P' + $(this).attr('id')).addClass('cornerimgfocus');
     }, function gallery() {
        clearTimeout(timerp);
        timerp = setTimeout(function() {
            var islide = $('.cornerimgfocus');
            $(islide).removeClass('cornerimgfocus');                    
            if(islide[0]==$('.cornerimg:last')[0]) {
            var nextslide =  $('.cornerimg').first();
            }
            else {
            var nextslide = $(islide).next();
            }
             gallery();
        }, 6000);
    });

Any ideas?

Marvellous

By the way, the mouseclick works perfectly it is only the timeout that I have not got correct.

I tried this. Still nothing. The click is still working but the timeout function is not.

$('.thumbs').click(function() {
         clearTimeout(timerp);
         $('.cornerimgfocus').removeClass('cornerimgfocus');
         $('#P' + $(this).attr('id')).addClass('cornerimgfocus');
         timerp = setTimeout(function() {
         $('#' + $(this).attr('id')).next().click()
         }, 3000)

    });

I thought that if I added the .next().click() it would reactivate this click function but it doesn’t. How do we achieve this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:58:17+00:00Added an answer on May 23, 2026 at 12:58 pm

    You’re passing two functions to the click() method, which is not supported. Also, it looks like you want setInterval() instead of setTimeout(), and you’re not adding the cornerimgfocus class to the next slide when the timer ticks. Try:

    var timerp = null;
    
    $('.thumbs').click(function() {
        if (timerp) {
            window.clearInterval(timerp);
        }
        $('.cornerimgfocus').removeClass('cornerimgfocus');
        $('#P' + $(this).attr('id')).addClass('cornerimgfocus');
        gallery();
    });
    
    function gallery()
    {
        timerp = window.setInterval(function() {
            var islide = $('.cornerimgfocus');
            islide.removeClass('cornerimgfocus');
            var nextSlide;
            if (islide[0] == $('.cornerimg:last')[0]) {
                nextslide = $('.cornerimg').first();
            } else {
                nextslide = islide.next();
            }
            nextSlide.addClass('cornerimgfocus');
        }, 6000);
    }
    
    gallery();  // Start the animation.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a JavaScript object, built this way: function foo() { this.length = 0;
I built up this regex at http://regextester.com to parse YSOD but VS is complaining
It seems like this should be something built into jQuery without the need for
Oracle's table server offers a built-in function, TRUNC(timestamp,'DY') . This function converts any timestamp
I'm hoping there is a built in .NET method to do this, but I'm
So I have here a JavaScript stack built after this function: function Stack() //Creating
Arguments are like this: function foo(arr1, arr2, arr3, arr4 ...) and the function should
Is there a built in jQuery function to determine the length of a scroll?
I have a string that looks like this: Name1=Value1;Name2=Value2;Name3=Value3 Is there a built-in class/function
I'm attempting to build a simple plugin like this (function($) { $.fn.gpSlideOut = function(options,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.