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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:34:38+00:00 2026-06-16T14:34:38+00:00

actully i want to develop slideshow which have two button say next and previous.

  • 0

actully i want to develop slideshow which have two button say next and previous.
so based on click event i want to swap images to next or previous position.
for that i write bellow code.

<script>
$("#nxt").live("click", function () {
  $("#img2").replaceWith("<img src='2.jpg'>");
  $("#img3").replaceWith("<img src='3.jpg'>");
  $("#img4").replaceWith("<img src='5.jpg'>");
  $("#img1").replaceWith("<img src='4.jpg'>");
});
</script>
<td>
  <input type="button" id="nxt" value="nxt" onclick="next()">
</td>
<td>
  <div id="img1">
    <img src="2.jpg">
  </div>
</td>
<td>
  <div id="img2">
    <img src="3.jpg">
  </div>
</td>
<td>
  <div id="img3">
    <img src="5.jpg">
  </div>
</td>
<td>
  <div id="img4">
    <img src="4.jpg">
  </div>
</td>

this code will swap all images on one click,but i want to swap only one image on one click.
next image on next click. how to do that?

  • 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-16T14:34:40+00:00Added an answer on June 16, 2026 at 2:34 pm

    Working code for rotating 4 images, next and prev implemented…

    jQuery

    <script>
        $(document).ready(function() {
            images = []
    
            $("#nxt").live("click", function () {
                for (i = 1; i <=4; i++) {
                    images[i] = $("#img" + i + " img").attr('src');
                }
    
                for (i = 1; i <=4; i++) {
                    if(i == 1) {
                        from = 4;
                    } else {
                        from = i - 1;
                    }
    
                    $("#img" + i + " img").attr('src', images[from]);
                }
            });
    
            $("#prev").live("click", function () {
                for (i = 1; i <=4; i++) {
                    images[i] = $("#img" + i + " img").attr('src');
                }
    
                for (i = 1; i <=4; i++) {
                    if(i == 4) {
                        from = 1;
                    } else {
                        from = i + 1;
                    }
    
                    $("#img" + i + " img").attr('src', images[from]);
                }
            });
        });
    </script>
    

    HTML

    <td>
      <input type="button" id="nxt" value="nxt">
    </td>
    <td>
      <div id="img1">
        <img src="2.jpg">
      </div>
    </td>
    <td>
      <div id="img2">
        <img src="3.jpg">
      </div>
    </td>
    <td>
      <div id="img3">
        <img src="5.jpg">
      </div>
    </td>
    <td>
      <div id="img4">
        <img src="4.jpg">
      </div>
    </td>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on python, i want to develop some simple web application which
What i want to do: Develop a Wordpress-based website with a local Wordpress installation
I want to develop the following application: on top I have a navigation bar,
I want to develop a simple iPhone application. However, I do not have the
I have some very heavy code to develop and want to make some calculations
Actually i want that, suppose i have a colorcode #FF3366. How can i examine
I have posted 3 queries here. Actually I want to join 1st & 2nd
I'm using Windows to develop android apps and want to know where user preference
I need to develop a client server system where I can have multiple clients
I have quite sometime now (a month or two) before I can actually start

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.