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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:37:58+00:00 2026-05-25T11:37:58+00:00

I want to make a gallery with thumbnails and a main picture frame, which

  • 0

I want to make a gallery with thumbnails and a main picture frame, which I managed to do. Now I want to link each picture to different .html. In case shown below all the pictures load c8.html when clicked upon, I only want c8.jpg to link to c8.html, c7.jpg to c7.html etc. From my understanding that problem occurs because “main-img” replaces for example c8.jpg with c7.jpg, and the code switches to <a href="c8.html"><img src="images/gallery/c7.jpg" id="main-img"/></a>.

Thank you for your time and help!

Andraz

<script>
    jQuery(document).ready(function($) {
        $("#gallery li img").click(function(){
            $('#main-img').attr('src',$(this).attr('src').replace('thumb/', ''));
        });
    });
</script>

<div id="gallery">
  <a href="c8.html"><img src="images/gallery/c8.jpg" id="main-img"/></a>
<ul>
  <li><img src="images/gallery/thumb/c1.jpg" alt=""/></li>
  <li><img src="images/gallery/thumb/c2.jpg" alt=""/></li>
  <li><img src="images/gallery/thumb/c3.jpg" alt=""/></li>
  <li><img src="images/gallery/thumb/c4.jpg" alt=""/></li>
  <li><img src="images/gallery/thumb/c5.jpg" alt=""/></li>
  <li><img src="images/gallery/thumb/c6.jpg" alt=""/></li>
  <li><img src="images/gallery/thumb/c7.jpg" alt=""/></li>
  <li><img src="images/gallery/thumb/c8.jpg" alt=""/></li>
</ul>
  • 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-25T11:37:59+00:00Added an answer on May 25, 2026 at 11:37 am

    You’ll just have to do the following in the click function

    $('#main-img').attr('src',$(this).attr('src').replace('thumb/', ''));
    $('#main-img').parent().attr('href',$(this).attr('src').match(/c\d/)[0]+".html");
    

    the /c\d/ regexp will match only up to 9, if you have more, you’ll have to change that a bit.

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

Sidebar

Related Questions

I want to make a gallery with only one preview picture and thumbnails helper.
I want to make a gallery which scrolls left and right depending on the
I want to make a little gallery and add next/previous buttons. I managed to
I want to make a javascript image gallery (with 6 thumbnails in a row
I'm using FancyBox, and I want to make a gallery without thumbnails on the
Here is the example. What I want is to make that thumbnails gallery remain
I want to make a pure CSS gallery/slideshow, which would use a sort of
I want to make an automated sliding picture gallery using the JQuery plugin http://slidesjs.com/
I want make a bash script which returns the position of an element from
I am traversing a HTML document using javascript DOM. I want make a list

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.