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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:47:30+00:00 2026-05-25T01:47:30+00:00

I have been asked to make a change to our website (it uses asp

  • 0

I have been asked to make a change to our website (it uses asp [about which I know nothing]), a solution based on css and javascript would be easier for me.

Is it possible to have a graphic on the webpage change when the user moves the cursor over a certain <li> item, eg.

  • option 1
  • option 2
  • option 3

When the mouse is moved over option 1 it will result in a certain picture being shewn, another for option 2 and a different one again for option 3.

  • 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-25T01:47:31+00:00Added an answer on May 25, 2026 at 1:47 am

    Given the following HTML:

    <ul>
        <li>Some text</li>
        <li>Some text</li>
    </ul>
    
    <img src="http://davidrhysthomas.co.uk/playtime/img/dwLogoS.png" id="graphic" />
    

    And the JavaScript:

    var lis = document.getElementsByTagName('li');
    var graphic = document.getElementById('graphic');
    var originalGraphic = graphic.src;
    for (i=0; i<lis.length; i++){
        lis[i].onmouseover = function(){
            graphic.src = "http://davidrhysthomas.co.uk/linked/astrid_avatar.png";
        };
        lis[i].onmouseout = function(){
            graphic.src = originalGraphic;
        };
    }
    

    This is certainly possible.

    If you want to amend this so that each li triggers a specific image to appear, then you can cause that using the following, or something similar:

    var lis = document.getElementsByTagName('li');
    var graphic = document.getElementById('graphic');
    var originalGraphic = graphic.src;
    for (i=0; i<lis.length; i++){
        lis[i].onmouseover = function(){
            graphic.src = "http://example.com/path/to/images/" + i + ".png";
            // this generates image sources of the form:
            // http://example.com/path/to/images/1.png
            // http://example.com/path/to/images/2.png
            // ...and so forth
        };
        lis[i].onmouseout = function(){
            graphic.src = originalGraphic;
        };
    }
    

    To use an array of image sources, it’s possible to use:

    var lis = document.getElementsByTagName('li');
    var graphic = document.getElementById('graphic');
    var originalGraphic = graphic.src;
    var images = [
        "http://davidrhysthomas.co.uk/linked/astrid_avatar.png",
        "http://davidrhysthomas.co.uk/img/dexter.png"
        ];
    for (i=0; i<lis.length; i++){
        lis[i].setAttribute('data-altimage',images[i]);
        lis[i].onmouseover = function(){
            graphic.src = this.getAttribute('data-altimage');
        };
        lis[i].onmouseout = function(){
            graphic.src = originalGraphic;
        };
    }
    

    JS Fiddle demo.

    And, finally, to leave the replaced image on the page (rather than replacing the original source of the image onmouseout), simply remove the onmouseout function:

    var lis = document.getElementsByTagName('li');
    var graphic = document.getElementById('graphic');
    var originalGraphic = graphic.src;
    var images = [
        "http://davidrhysthomas.co.uk/linked/astrid_avatar.png",
        "http://davidrhysthomas.co.uk/img/dexter.png"
        ];
    for (i=0; i<lis.length; i++){
        lis[i].setAttribute('data-altimage',images[i]);
        lis[i].onmouseover = function(){
            graphic.src = this.getAttribute('data-altimage');
        };
    }
    

    JS Fiddle demo.

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

Sidebar

Related Questions

I have been asked to make some customisation changes to our Dynamics CRM 4.0
I have been asked to make a few cosmetic changes to our production deployment.
I've been asked to make a small change to one of our RDLs. Essentially,
I have been asked to migrate some code to our new asp.net web app.
I have been asked to post a new question about how to correctly sort
I have been asked to set up some authentication for some content on our
i have been asked to make a marketing site.The concept provided is as follows-
I'm aware that questions have been asked and answered about the Android soft keyboard
I know that variations on this question have been asked, but I've tried all
I know this question has been asked several times for sure, but I have

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.