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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:17:20+00:00 2026-06-04T19:17:20+00:00

My HTML page has an image with id img. The idea is that by

  • 0

My HTML page has an image with id img. The idea is that by clicking first, previous, or next, the user can navigate through a set of images. How do I do this using JavaScript?

  • 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-04T19:17:22+00:00Added an answer on June 4, 2026 at 7:17 pm

    This should be a good start for you:

    <script>
      var imgs = ["img1.png","img2.png","img3.png"]; // copy images to the same dir
      var index = 0;
    </script>
    <img src="img1.png" onclick="this.src=imgs[++index%imgs.length]"/>
    

    click the image to slide.

    If you need buttons, see this example:

      <img id="clicker" src="img1.png"/>
      <a href="#" onclick="prev(); return false;">Prev</a>
      <a href="#" onclick="next(); return false;">Next</a>
      <a href="#" onclick="first(); return false;">First</a>
      <a href="#" onclick="last(); return false;">Last</a>
    <script>
      var imgs = ["img1.png","img2.png","img3.png"];
      var index = 0;
      var clicker = document.getElementById("clicker");
      function prev() { clicker.src = imgs[--index%imgs.length]; }
      function next() { clicker.src = imgs[++index%imgs.length]; }
      function first() { clicker.src = imgs[index=0]; }
      function last() { clicker.src = imgs[index=imgs.length-1]; }
    </script>
    

    The return false means that default action on click (follow the link) is supressed. Javascript can access elements i.e. using id (see clicker here). Once you get comfortable with this and you start to solve browser compatibility problems, it is good idea to continue with jQuery (as the other suggests), MooTools or other framework.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have an HTML page that has many textboxes that need to be
I'm developing web page which has main file index.php as follows: include('UserClass.php'); include('html/top.php'); $user
I have a page that I need to design in PhP/Html/Java/CSS that has to
So I have a html page that has a form, and a table inside
I have a C# webbrowser that holds an html page that has several iframes.
I have a cherryPy program that returns a page that has an image (plot)
I have a product page that has image thumbnails and links bellow for front
I need to create a link for an ASP.NET page that has an image
I have a web page with a jpg image that the user draw an
A form on my website's contact -us HTML page has two fields 1) subject

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.