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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:53:52+00:00 2026-06-02T18:53:52+00:00

I currently have a small working JS gallery (onmouseover). The code is below. What

  • 0

I currently have a small working JS gallery (onmouseover). The code is below. What I would like to achieve is the small images, only a few being displayed at a time. I have found a youtube video of the affect I would like to achieve: video

HTML (code omitted):

<div id="imagecontent">
     <img id="about_mojang" src="images/about_mojang_small.jpg" alt="Plain Mojang Logo">
     <img id="about_lego" src="images/about_lego_small.jpg" alt="Minecraft Lego">
     <img id="about_cteam" src="images/about_cteam_small.jpg" alt="Cartoon of the Mojang team">
     <img id="about_minecraftmojang" src="images/about_minecraftmojang_small.jpg" alt="Minecraft logo of Mojang">
     <img id="about_team" src="images/about_team_small.jpg" alt="Photo of the Moajgn team">
     <img id="about_wall" src="images/about_wall_small.jpg" alt="A wall in the Mojang office">
</div>
<div id="bigimage"></div>
<script>window.onload=addImages() ;</script>
</body>

JS (code omitted):

function showPic(i_element) {
  var source = i_element.getAttribute("id") ;
  source  = "images/"+source+".jpg" ;
  var alt = i_element.getAttribute("alt") ;

  var i = document.createElement("img") ;
  i.setAttribute("src",source) ;
  i.setAttribute("alt",alt) ;

  var placeholder = document.getElementById("bigimage") ;
  if (placeholder.childNodes.length != 0 ) 
  {  placeholder.removeChild(placeholder.childNodes[0]); }
  placeholder.appendChild(i) ;

}


//  add the onclick event to the DOM
function addImages() {
    var item = document.getElementById("imagecontent").getElementsByTagName("img") ;
    for (var i=0 ; i<item.length ; i++) {
      item[i].onmouseover = function() {showPic(this) ; } ;
    }

}
  • 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-02T18:53:54+00:00Added an answer on June 2, 2026 at 6:53 pm

    check jsfiddle output: http://jsfiddle.net/srinivasan/EfyKe/

    try something like this

     <html xmlns="http://www.w3.org/1999/xhtml">
                <head>
                <script src="http://code.jquery.com/jquery-latest.js"></script>
                <script type="text/javascript">
                function showPic(i_element) {
                  var source = i_element.getAttribute("id") ;
                  source  = "images/"+source+".jpg" ;
                  var alt = i_element.getAttribute("alt") ;
    
                  var i = document.createElement("img") ;
                  i.setAttribute("src",source) ;
                  i.setAttribute("alt",alt) ;
    
                  var placeholder = document.getElementById("bigimage") ;
                  if (placeholder.childNodes.length != 0 ) 
                  {  placeholder.removeChild(placeholder.childNodes[0]); }
                  placeholder.appendChild(i) ;
    
                }
    
    
                //  add the onclick event to the DOM
                function addImages() {
                    var item = document.getElementById("imagecontent").getElementsByTagName("img") ;
                    for (var i=0 ; i<item.length ; i++) {
                      item[i].onmouseover = function() {showPic(this) ; } ;
                    }
    
    
                }
    
    
    
    
    
                </script>
                <style>
    
                </style>
                </head>
                <body>
                <div id="bigimage" style="height:50px; width:100px; border:1px solid red; margin:0 auto;"></div>
                <div id="prev" style=" width:50px; height:25px; float:left;" ><img src="http://dummyimage.com/25x25/900/FFF.jpg&text=PREV" /></div>
    
                <div id="imagecontent" style="width:400px; margin:0 auto; border:1px solid red; height:50px;position:relative; overflow:hidden; ">
                <div id="slider" style="width:400px;  float:left; overflow:hidden; position:absolute; " >
    
                     <img id="about_mojang" src="http://dummyimage.com/50x50/000000/fff.jpg&text=VS" alt="Plain Mojang Logo">
                     <img id="about_lego" src="http://dummyimage.com/50x50/000000/fff.jpg&text=VS" alt="Minecraft Lego">
                     <img id="about_cteam" src="http://dummyimage.com/50x50/000000/fff.jpg&text=VS" alt="Cartoon of the Mojang team">
                     <img id="about_minecraftmojang" src="http://dummyimage.com/50x50/000000/fff.jpg&text=VS" alt="Minecraft">
                     <img id="about_team" src="http://dummyimage.com/50x50/000000/fff.jpg&text=VS" alt="Photo of the Moajgn team">
                     <img id="about_wall" src="http://dummyimage.com/50x50/000000/fff.jpg&text=VS" alt="A">
                     <img id="about_team" src="http://dummyimage.com/50x50/000000/fff.jpg&text=VS" alt="Photo of the Moajgn team">
                     <img id="about_team" src="http://dummyimage.com/50x50/000000/fff.jpg&text=VS" alt="Photo of the Moajgn team">
                     <img id="about_wall" src="http://dummyimage.com/50x50/000000/fff.jpg&text=VS" alt="A">
    
                </div>
                </div>
                <div id="next" style=" float:right; width:25px; height:25px;"><img src="http://dummyimage.com/25x25/900/FFF.jpg&text=NEXT" /></div>
    
                <script>window.onload=addImages() ;</script>
                <script type="text/javascript">
                var i=0;
                var speed=5;
                  $("#next").click(function(){
                      i=document.getElementById('slider').style.left;
                        i=(i.replace("px",""));
                      for(j=0;j<speed;j++){
                    $("#slider").animate({left:i},"fast");
                    i=i-60;
                      }
    
                   });
    
    
                 $("#prev").click(function(){
                     i=document.getElementById('slider').style.left;
                     i=(i.replace("px",""));
                     if(i!='0'&&i<'0'){
                      for(j=0;j<speed;j++){
                    $("#slider").animate({left:i},"fast");
                    i=parseInt(i)+parseInt(60);
                      }
                     }
                     else{
                         $('#prev').attr('disabled', '');
                     }
                   });
                </script>
                </body>
                </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a small Java program which I would like to run both
I'm currently working on a small project and would like some help on it.
I am working with a small theatre company. Currently they have a list of
I am working on a small utility where I would like to change the
I am currently working on my final thesis.I have a small problem.I need to
I'm currently working on a small game that consisted of a few targets that
I currently have a small laptop and a desktop (+ gaming rig) that I
I currently have a small text game I've written in Java that utilizes System.out.print();
We (small team) currently have our Visual Studio projects on a network drive (no
I currently have a varchar(255) column that stores the path to a small image

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.