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 7458511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:27:25+00:00 2026-05-29T13:27:25+00:00

I have asked and done the follow code: $(document).ready(function() { $(‘.gallery’).each(function(index, element) { var

  • 0

I have asked and done the follow code:

$(document).ready(function() {
    $('.gallery').each(function(index, element) {
        var id = $(this).attr('id');
        var images = $('#' + id + ' .content li').index() -1;

        $('#' + id + ' .prev').click(function(e) {
            e.preventDefault();

            if($('#' + id + ' .content .current').prev().length == 0 ) {
                $('#' + id + ' .content .current').fadeOut(1000).removeClass('current').hide();
                $('#' + id + ' .content li:last').fadeIn(1000).addClass('current').show();
            } else {
                $('#' + id + ' .content .current').removeClass('current').fadeOut(1000).hide().prev().fadeIn(1000).addClass('current').show();
            }

            return false;
        });

        $('#' + id + ' .next').click(function(e) {
            e.preventDefault();

            if($('#' + id + ' .content .current').next().length == 0 ) {
                $('#' + id + ' .content .current').fadeOut(1000).removeClass('current').hide();
                $('#' + id + ' .content li:first').fadeIn(1000).addClass('current').show();
            } else {
                $('#' + id + ' .content .current').removeClass('current').fadeOut(1000).hide().next().fadeIn(1000).addClass('current').show();
            }

            return false;
        });

        $('#' + id + ' .thumbnails li').click(function(e) {
            e.preventDefault();

            $('#' + id + ' .content .current').removeClass('current').hide();
            $('#' + id + ' .content .thumbnails').removeClass('current');
            $('#' + id + ' .content li').eq($(this).index()).fadeIn(1000).addClass('current').show();

            return false;
        });

        $('#' + id + ' .thumbnails ul').css('width', $('#' + id + ' .thumbnails ul li').length * scrollWidth + 'px');
        $('#' + id + ' .content li:first').addClass('current').show();
    });
});

The html:

<div id="galerry-one" class="gallery">
    <div class="content">
        <ul>
            <li id="content-1"><img src="image1.jpg" /></li>
            <li id="content-2"><img src="image2.jpg" /></li>
            <li id="content-3"><iframe src="http://www.youtube.com/..."></iframe></li>
            <li id="content-4"><img src="image3.jpg" /></li>
            <li id="content-5"><iframe src="http://www.youtube.com/..."></iframe></li>
        </ul>
    </div>
    <div class="thumbnails">
        <span class="prev"> « </span>
        <ul>
            <li id="go-content-1"><img src="image1_thumbnai.jpg" /></li>
            <li id="go-content-2"><img src="image2_thumbnai.jpg" /></li>
            <li id="go-content-3"><img src="youtube1_thumbnai.jpg" /></li>
            <li id="go-content-4"><img src="image3_thumbnai.jpg" /></li>
            <li id="go-content-5"><img src="youtube2_thumbnai.jpg" /></li>
        </ul>
        <span class="next"> » </span>
    </div>
</div>

The problem now is, how I can limit to 4 thumbnails each time I click previous/next?

  • 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-29T13:27:26+00:00Added an answer on May 29, 2026 at 1:27 pm

    I had a similar implementation for showing 4 items and scroll with Prev/Next option. So I just modified a bit for it to work with your html.. Check my DEMO

    Change elToShow var to customize how many thumbnails you wanted to show.

    var stPt = 0, elToShow = 4; //showing 4 elements
    
    var $ul = $('.thumbnails ul');
    var $li = $('.thumbnails ul li'); //get the list of li's
    var $copy_li = [];
    var copy_lgt = $li.length - elToShow;
    
    //call to set thumbnails based on what is set
    initNav();
    function initNav() {
       var tmp;
       for (var i = elToShow; i < $li.length; i++) {
          tmp = $li.eq(i);
          $copy_li.push(tmp.clone());
          tmp.remove();
       }
    }
    
    $('.next').click (function () {
        $li = $('.thumbnails ul li'); //get the list of li's
    
        //move the 1st element clone to the last position in copy_li
        $copy_li.splice(copy_lgt, 0, $li.eq(0).clone() ); //array.splice(index,howmany,element1,.....,elementX)
    
        //kill the 1st element in the UL
        $li.eq(0).remove();
    
        //add to the last
        $ul.append($copy_li.shift());
    });
    
    $('.prev').click (function () {
        $li = $('.thumbnails ul li'); //get the list of li's
    
        //move the 1st element clone to the last position in copy_li
        $copy_li.splice(0, 0, $li.eq(elToShow-1).clone()); //array.splice(index,howmany,element1,.....,elementX)
    
        //kill the 1st element in the UL
        $li.eq(elToShow-1).remove();
    
        //add to the last
        $ul.prepend($copy_li.pop());
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The below code is from my other questions that I have asked here on
I have asked a similar question before, but I didn't have a firm grasp
I have asked this before but I didn't get the question right so the
I have asked this question before and the problem was half solved in the
I have asked this on the castle list as i'm using the nh facility
i have asked to create a module that will record video messages form the
I have asked this question on Telerik forums with no reply so I'm turing
I have asked similar question for Linux RPM ( Adding License Agreement in RPM
I have asked What should i know about search engine crawling? Now i would
Previously I have asked to strip text from a field and convert it to

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.