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

  • Home
  • SEARCH
  • 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 9168611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:39:57+00:00 2026-06-17T15:39:57+00:00

I created a image loop by using jquery and it works fine. Here is

  • 0

I created a image loop by using jquery and it works fine. Here is my code.

$(document).ready(function(){
    $('.images').hide();    
    $('#image1').show('slide', {direction: 'right'}, 500);
    $('#image1').delay(2000).hide('slide', {direction: 'left'}, 500);
    var sc = $('#image img').size();
    var count = 2;
    setInterval(function(){
        $('#image'+count).show('slide', {direction: 'right'}, 500);
        $('#image'+count).delay(2000).hide('slide', {direction: 'left'}, 500);
        if(count == sc){
            count = 1;
        }else{
            count = count + 1;
        }
    }, 3000);

    $('.name').click(function(){
        var name = $(this).attr('id');
        name = name.replace('name', '');
        count = name;
    });
});

Here is the html code.

                    <div id="image">
                        <img class="images" id="image1" alt="Image loop" src="image1.jpg" width="550px" height="400px"/>
                        <img class="images" id="image2" alt="Image loop" src="image2.jpg" width="550px" height="400px"/>
                        <img class="images" id="image3" alt="Image loop" src="image3.jpg" width="550px" height="400px"/>
                        <img class="images" id="image4" alt="Image loop" src="image4.jpg" width="550px" height="400px"/>
                        <img class="images" id="image5" alt="Image loop" src="image5.jpg" width="550px" height="400px"/>
                    </div>
                    <div id="name">
                        <div class="name" id="name1">
                            <img src="image1.jpg" width="80px" height="80px"/>
                        </div>
                        <div class="name" id="name2">
                            <img src="image2.jpg" width="80px" height="80px"/>
                        </div>
                        <div class="name" id="name3">
                            <img src="image3.jpg" width="80px" height="80px"/>
                        </div>
                        <div class="name" id="name4">
                            <img src="image4.jpg" width="80px" height="80px"/>
                        </div>
                        <div class="name" id="name5">
                            <img src="image5.jpg" width="80px" height="80px"/>
                        </div>

The css controls the name sets to the right. My idea is, click the small image on the right to immediately switch the image which user choose.
enter image description here
It seems working a little bit. The setInterval is still runing and the loop is ruined. How can I deal with this properly? Here is the jsfiddle link. Thanks!

  • 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-06-17T15:39:59+00:00Added an answer on June 17, 2026 at 3:39 pm

    The problem occurs because you change the type of count from a number to a string inside your click handler – when you assign name to count. I’ve edited your code to include parseInt.

        $('.name').click(function(){
        var name = $(this).attr('id');
        name = name.replace('name', '');
        count = parseInt(name, 10);  
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div which in jquery's document ready I append - using $(#div
So say I've got a series of images created with a php loop ->
I created an image fading slideshow reading this article . The code looks like
I have created jquery image slider and it is working good. However i have
I created an .png image from a video using ffmpeg tool and i want
I am using a JavaScript function and some jQuery to perform two actions on
I am using jQuery's ajax function $.get() to download data from a page. I
I am using the following HTML & PHP code to move multiple images to
I am using a jQuery plugin that has an event handler whose return function
I am using this code for displaying Images in scroll view... In this buttons

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.