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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:43:23+00:00 2026-06-10T09:43:23+00:00

I have 10 images on a page which has 2 buttons: next and previous.

  • 0

I have 10 images on a page which has 2 buttons: next and previous. On next I want to go from the 1st to 10th image and vice versa for previous button.
This is my html code:

   <div id="Div1"> <img class='display' src=""  alt="adf"/></div>
    <button id="Button1">prev</button>
    <button id="Button2">next</button>
<div id='Div2'>
     <img src="a_large.jpg" alt="aadf" />
    <img src="b_large.jpg" alt="dfD" />
     <img src="c_large.jpg" alt="aadf" />
    <img src="d_large.jpg" alt="dfD" />
     <img src="e_large.jpg" alt="aadf" />
    <img src="f_large.jpg" alt="dfD" />
     <img src="g_large.jpg" alt="aadf" />
    <img src="h_large.jpg" alt="dfD" />
     <img src="i_large.jpg" alt="aadf" />
    <img src="j_large.jpg" alt="dfD" />
    </div>

I am newbie to jQuery. Can you please tell me the code for next and previous buttons.
Thanks in advance.

  • 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-10T09:43:24+00:00Added an answer on June 10, 2026 at 9:43 am

    Don’t keep all images within the div when you need to show only 1. Keep the names of the images within an array, like:

    arrimg = ['a_large.jpg','b_large.jpg','b_large.jpg'...'j_large.jpg']
    

    Keep only the first image initially, with a value of 0 for the ind property:

    <div id='Div2'>
      <img src="a_large.jpg" alt="aadf" ind = '0' />
    </div.
    

    Then do something like (assign your to buttons a class of say button to reduce the number of lines of code):

    $(".button").click(function() {
       if ($(this).prop('id') == 'Button1') {
         if ($("#Div2 img").prop('ind') != 0) {
            ind = parseInt($("#Div2 img").prop('ind'));
            $("#Div2 img").prop({'src': arrimg[ind-1],'ind':(ind-1)+"");
        }
        else {
             $("#Div2 img").prop({'src': arrimg[9],'ind':'9');
        }
        }
        else {
           if ($("#Div2 img").prop('ind') != 9) {
            ind = parseInt($("#Div2 img").prop('ind'));
            $("#Div2 img").prop('src': arrimg[ind+1],'ind': (ind+1)+"");
        }
        else {
             $("#Div2 img").prop('src': arrimg[0],'ind':0});
        }
        }          
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have been given a site xyz.com, in which the home page has images
I have a list of images which I want to display in a page.
i have a jsf page which displays an image from an url http://ichart.finance.yahoo.com/z?s=^NSEI&t=1d&q=l&l=on&z=l&p=s&a=v&p=s i
We are using Sharepoint 2007 In which on master page we have Asp Image
I have a background on a page body that is an image which I
I have a web page, used for admin purposes, which runs a task (image
a I have some images on page and I want to put <span> tag
I have a page of search results, each of which has an icon to
I have 3rd party user control (a captcha control), which has a captcha image,
I have a web page where I create images from text by clicking a

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.