JavaScript Image Thumbnails Preview Gallery

Today, We want to share with you JavaScript Image Thumbnails Preview Gallery.In this post we will show you javascript image gallery with thumbnails, hear for CSS Image Thumbnail Viewer in javascript Gallery we will give you demo and example for implement.In this post, we will learn about Responsive Image Gallery with Thumbnail Carousel with an example.

JavaScript Image Thumbnails Preview Gallery

There are the Following The simple About JavaScript Image Thumbnails Preview Gallery Full Information With Example and source code.

As I will cover this Post with live Working example to develop jQuery Thumbnail Image Slider – CSS, JavaScript, so the css image gallery with thumbnails for this example is following below.

Example 1: JavaScript Image Thumbnail Viewer Tutorial


<!DOCTYPE html>
<meta charset="utf-8" />
<title>Simple javascript image gallery with thumbnails |</title>
.liveimgpreview {

.gallerythumb {

.defaultset {
border:3px solid #000000;}

.selected {
border:3px solid #ff0000;}
<h1>Image Thumbnail Viewer</h1>
<img id="0" class="liveimgpreview defaultset" src="" alt="preview" /><br />
<img id="1" class="gallerythumb defaultset" src="YOUR IMAGES BASE PATH" alt="Product1" onmouseover="liveimgpreview(this)"/>
<img id="2" class="gallerythumb defaultset" src="YOUR IMAGES BASE PATH" alt="Product2" onmouseover="liveimgpreview(this)"/>
<img id="3" class="gallerythumb defaultset" src="YOUR IMAGES BASE PATH" alt="Product3" onmouseover="liveimgpreview(this)"/>

    var lastImg = 1; //Set initial thumbnail and liveimgpreview
    document.getElementById(0).src = document.getElementById(lastImg).src;
    document.getElementById(lastImg).className = "gallerythumb selected";

    function liveimgpreview(img_param) {
        document.getElementById(lastImg).className = "gallerythumb defaultset";
        img_param.className = "gallerythumb selected";
        document.getElementById(0).src = img_param.src;
        lastImg =

Example 2: Simple JavaScript Image Thumbnail Viewer

    <title>JavaScript Thumbnail Slider</title>
    <style type="text/css">
        .img_container {
            margin: 0 auto;
            width: 191px;
            height: 113px;    
            border: 0;
            overflow: hidden;
            background-color: #FFFFFF;
            webkit-box-shadow: 2px 0 10px rgba(0,0,0,0.2), -2px 0 10px rgba(0,0,0,0.2);
            -moz-box-shadow: 2px 0 10px rgba(0,0,0,0.2), -2px 0 10px rgba(0,0,0,0.2);
            box-shadow: 2px 0 10px rgba(0,0,0,0.2), -2px 0 10px rgba(0,0,0,0.2);    
            border: solid 0px #FFFFFF; 
            border-radius: 4px;
            -moz-border-radius: 4px;
            -webkit-border-radius: 4px;    
            display: block;
        #gallery {
            margin:0 auto;
        .thumbnailSlide {
        .thumbnailSlide .btSld {
            border:solid 2px #FFFFFF;
    <p>Click the little circles below the Product Thumb to slide</p> 
    <div class="img_container">
        <a href="#" rel="">
            <img src="" id="pb1" alt="" border="0" />
    <div id="gallery">
        <div class="thumbnailSlide">
            <input type="button" id="1" class="btSld" 
                onclick="javascript:previewThumb(;" />
            <input type="button" id="2" class="btSld" 
                onclick="javascript:previewThumb(;" />
            <input type="button" id="3" class="btSld" 
                onclick="javascript:previewThumb(;" />
            <input type="button" id="4" class="btSld" 
                onclick="javascript:previewThumb(;" />

    var array_Thumb = new Array();  

    array_Thumb[1] = '';
    array_Thumb[2] = '';
    array_Thumb[3] = '';
    array_Thumb[4] = '';

    var setThumb;
    var thumbnailCounter = array_Thumb.length - 1;

    var arrThumbCnt = new Array();
    for (setThumb = 1; setThumb < thumbnailCounter + 1; setThumb++) {
        arrThumbCnt[setThumb] = new Image();
        arrThumbCnt[setThumb].src = array_Thumb[setThumb];
    function previewThumb(img) {
        document.images.pb1.src = arrThumbCnt[img].src;
        for (setThumb = 1; setThumb < thumbnailCounter + 1; setThumb++) {
            if (setThumb == img) 
                document.getElementById(setThumb).style.backgroundColor = "#567DD8";
                document.getElementById(setThumb).style.backgroundColor = "#CCC";

Angular 6 CRUD Operations Application Tutorials

Read :

Read Also:  Laravel Get Current DateTime Handling in PHP with Carbon


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about JavaScript Image Thumbnails Preview Gallery.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  failed to load resource: the server responded with a status of 404 (not found)
  2. Read Also:  jquery datetimepicker change Date format Dynamically
  3. Read Also:  jQuery Full screen Navigation Overlay
  4. Read Also:  Laravel 5.6 PDF Generation using Dompdf Example
  5. Read Also:  PHP Quiz Application Using jQuery Ajax MySQL and Bootstrap
  6. Read Also:  PHP Arrays Example Tutorial For Beginners From Scratch
  7. Read Also:  Get Drop Down List of TimeZones using PHP
  8. Read Also:  get product with Rakuten Marketing API using PHP
  9. Read Also:  Image Overlay Hover Effects With CSS3 Transitions
  10. Read Also:  Jquery .next() and .prev() functions example