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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:16:18+00:00 2026-06-15T13:16:18+00:00

I have a Javascript that runs a Thumbnail viewer: var lastID = 0; function

  • 0

I have a Javascript that runs a Thumbnail viewer:

var lastID = 0;
function SelectImg(id) {
    if (lastID > 0) {
        document.getElementById(lastID).className = "thumbNormal";
    }
    document.getElementById(id).className = "thumbSelected";
    document.getElementById(0).src = document.getElementById(id).src;
    lastID = id;
}
function LoadTrigger() {
    SelectImg(1);
}
window.onload = LoadTrigger;

The HTML for three images would be this

<tbody>
    <tr>
        <td class="image">
            <img id=0 src="<?=$row['picture_noglow']?>"
            onmouseover="this.src='imgs/collection/KN/main/KNB01_Ga.jpg'"
            onmouseout="this.src='imgs/collection/KN/main/KNB01_Na.jpg'">
        </td>
        <td class="imagestack">
            <img id=1 class="thumbNormal" src="<?=$row['picture_noglow']?>" width=70 onclick="SelectImg(1)" /><p>
            <img id=2 class="thumbNormal" src="imgs/collection/defaultcase_backview_black.jpg" width=70 onclick="SelectImg(2)"><p>
            <img id=3 class="thumbNormal" src="imgs/collection/defaultcase_sideview_black.jpg" width=70 onclick="SelectImg(3)">
        </td>
    </tr>
</tbody>

I want to apply a rollover to id=1 only, so that when the first image is selected it will have a rollover effect. If I selected image 2 or 3, the rollover stops.

Right now when I selected image 2 or 3, the rollover will still happen.

  • 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-15T13:16:19+00:00Added an answer on June 15, 2026 at 1:16 pm

    You just have to test if the image with id=1 is selected :

    function mouseOverFirstImage() {
       var img1 = document.getElementById("1");
    
       // Test if the image is selected (if more than 1 class can
       // be applied change this test to "img1.className.match(/thumbSelected/)"
       if(img1.className === "thumbSelected")
           document.getElementById("0").src = <newImageSrc>;
    }
    
    function mouseOutFirstImage() {
       var img1 = document.getElementById("1");
    
       if(img1.className === "thumbSelected")
           document.getElementById("0").src = <normalImageSrc>;
    }
    
    function LoadTrigger() {
        // Add the 3 following lines to this function
        // in order to have a rollover effect
        var mainImage = document.getElementById("0");
        mainImage.onmouseover = mouseOverFirstImage;
        mainImage.onmouseout = mouseOutFirstImage;
    
        SelectImg(1);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript function that runs every 3 seconds, is there any way
I have a javascript that displays a generated text into a div: document.getElementById('phrase').innerHTML =
I have a javascript function that I am trying to add to my document,
In Javascript, I have two versions of a recursive function, one that runs synchronously
I have the following javascript code that runs when a page is closed. $(window).unload(function
I have a recursive type function in Javascript that runs like this: function loadThumb(thumb)
I have a javascript that runs using the onchange event when a user enteres
I have a javascript that calls a function each 1 minute. That function sends
I have a javascript that does this (http is your XMLHttpRequest object) var r
If I have a javascript class that runs some initialization code, it seems logical

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.