Basic picture alteration

One of the elements in my project is a big cover photo, with five smaller thumbnail images underneath it.

I am looking to create an interactive feature where clicking on one of the thumbnails will change the large image to match the selected thumbnail.

I have been struggling to find information on how to implement this functionality as I'm not sure what it's called.

Any assistance on this matter would be highly appreciated.

Answer №1

This type of display is commonly known as an image gallery/slider and typically requires the use of javascript or jQuery for implementation.

If you're looking to learn more about creating image galleries with jQuery, check out these examples and tutorials.

Answer №2

If you're looking for guidance on how to implement a gallery, this example may help:

<div class="gallery">

    <div id="mainViewport" class="viewport">
        <img src="my-picture.jpg" alt=""/>
    </div>

    <ul class="thumbnails">
        <li><img src="imgs/my-picture-thumbnail.jpg" alt=""/></li>
        <li><img src="imgs/my-picture2-thumbnail.jpg" alt=""/></li>
        <li><img src="imgs/my-picture3-thumbnail.jpg" alt=""/></li>
    </ul>
</div>


<script>
    var mainViewport = $('#mainViewport');
    $('.thumbnails img').click(function(){
        var path = $(this).attr('src').replace('-thumbnail','');
        var mainImg = new Image();
        mainImg.src = path;
        mainViewport.html(mainImg);

    });   
</script>

To make this work, ensure your thumbnails are named as 'path/to/full/img-thumbnail.jpg' and strip the '-thumbnail' part in the script to display the full-size image in the mainViewport div.

For a live demo, check out: http://jsfiddle.net/wbT4N/1/

Remember to have both thumbnail and full-sized versions of your images for this to work properly.

Best of luck!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

CSS for arranging products in varying sizes of divs to create a structured layout

Hey there! I'm looking to showcase my products in a similar layout as the one in this image. However, I'm struggling with figuring out how to apply different sizes to each div containing product information. Are there any CSS or jQuery plugins a ...

Creating image filters using an object in jQuery

I am faced with a challenge where I have multiple image tags nested within a div that has the class google-image-layout. Each image is equipped with various data attributes, including: data-anger="0" data-disgust="0" data-facedetected="0" data-fear="0" da ...

Issue on WordPress where JQuery is undefined causing continuous refreshing on IPhone devices

My wordpress website is performing well in most browsers, including some mobile ones. However, when accessed on an IPhone, the homepage keeps refreshing in a continuous loop. Even after emulating an IPhone using Chrome developer tools, the issue persists. ...

Enhancing Text Clarity on iOS Devices

I've created a webapp that works smoothly on the majority of mobile devices. However, I've noticed that occasionally on my iPhone 5s (and I've heard similar experiences from users on other iOS devices), the text appears blurry. This issue se ...

The vanilla JS router seems to be malfunctioning, as it is only showing the [object XMLDocument]

Recently, I attempted to implement routing into my JavaScript application using the following example: link. However, after diligently copying every file from the project, all I see displayed inside the <main></main> tags is "[object XMLDocum ...

Why does Socket.IO seem to be registering two clients instead of just one when there is only one connection

When using my app, the user first lands on the home screen where they can select their username. They then proceed to another page and from there, navigate to the room entry page. The issue I'm facing is with a specific section of my code that update ...

Tips for retrieving the value of an input field using Material-UI

Currently, I am implementing Material-UI within a React project. render(){return ( <input type="range" min="0" max="100" value="100" onChange={this.handleMasterVolume} class="master-gain form-control ...

Running a setTimeout function within the context of a jQuery each

My goal is to animate characters one by one, but for some reason the following code isn't functioning as expected: $('.overlay-listing').hover(function(){ var idx = 1; $('.strip-hov span', this).each(function(){ if ...

Creating multiple unique custom attributes for a specialized HTML element

Creating getter/setter methods for a custom attribute on a custom HTML element is quite simple: customElements.define('custom-el', class extends HTMLElement { static get observedAttributes() { return ['customAttr'] ...

import external script in the head using requirejs

Here is my unique HTML structure: <head> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta charset="utf-8"> <title>vente-privee.com</title> <script src="@Url.Content("~/Scripts/Modules/lib/j ...

Where is the best place to implement HTML form validation: on the frontend or backend?

Is it important to validate all values before submitting the form to the backend server, as mentioned in the title? ...

Uploading files using ReactJS Ajax

I'm having some trouble uploading a file using React and I need help figuring out the best approach. I've been trying to save the file on change, but it doesn't seem to be working correctly. Whenever I try to submit, I keep running into an e ...

Discovering the most efficient route on a looped set of items

My question may not be fully comprehensible, but essentially it involves the following scenario: I have created an interactive presentation that displays static images in a sequence to generate an animation. By clicking the Play button, the animation prog ...

Tips for preventing a column from extending beyond the edge of the browser window during resizing

Issue arises when I resize the browser window, causing the left box to extend beyond the browser boundary, making it impossible to see the contents even with the scrollbar below. <!DOCTYPE html> <html lang="en"> <head> ...

Unable to receive response from Jquery ajax

Here is the HTML content I have created. <!DOCTYPE html> <html lang="en"> <head> <title>Test page</title> <script language="javascript" type="text/javascript" src="jquery-1.5.1.min.js"></script> ...

Leveraging ajax beforeSend for data manipulation

Suppose I have a jQuery Ajax call like this: $.ajax({ url: myUrl, data: myData, type:'post' }); I want to enhance myData using $.ajaxSetup({ beforeSend: function(call){...} }); This modification should apply to all Ajax calls (b ...

How can I show the table row as an inner table row when the first field is identical?

<tr ng-model="check" ng-repeat="orderBook in orderBookDetails| orderBy: 'orderBook.no'" value='check=$scope.orderBookDetails.sowNo'> <td ng-if='check!=orderBook.no'>{{orderBook.no}}</td> <td>{{order ...

Expand the dimensions of the shinydashboard dashboard page

Currently, I am using shinydashboard and have formatted my ui code in the following way: ui = dashboardPage(skin="black", dashboardHeader(disable = T), dashboardSidebar(width=300), dashboardBody() ...

Utilizing AJAX response to update the current URL in a Spring MVC application - A step-by-step guide

In my ongoing project using Spring MVC, the homepage features two input fields of String type. However, the regNo field accepts numbers as input. If a user enters a regNo, it should be directed to a specific method in the controller. On the other hand, if ...

Guide on selecting a default value in a Datalist Dropdown in Angular

In my editable dropdown, I am looking to automatically populate the default value from a template. The default value is sourced from "this.Model.Application.environment" which contains "dev" as the value. The current code provides an editable dropdown, b ...