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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:56:08+00:00 2026-05-10T22:56:08+00:00

I am trying to do a multi rollover with Javascript. I know a lot

  • 0

I am trying to do a multi rollover with Javascript. I know a lot of people say to use css, but it’s going to be done in Javascript this time around.

Anyway, I am having much trouble with this rollover hierarchy. I have a button image nav with five buttons. When you mouseover one of the buttons, the button changes color AND a heading appears underneath for that button. The next part is that the user has to hover over the heading, and then ANOTHER image appears with text in it that describes the heading.

So, for example, the button might be a red smile, when you rollover it, it becomes a blue smile and then a heading appears underneath that says Happy. Then if you rollover happy, you get an image of text describing what it means to be happy. This is the way the client wants it and the only reason I am using an image of text, is because his text uses a unique font.

So, just to show you that I have been trying to code this and not looking for answer without the work, here’s my code so far. It kind of works, but it’s not great and I’m not so familar with javascript.

function rollover() {   var images = document.getElementsByTagName('img');   var roll = new RegExp('roll');   var header = new RegExp('_(?=roll)');   var text = new RegExp('_(?=text)');   var simple = new RegExp('simple');   var currentRoll;   var preload = [];   var fileLoc = 'images/rollovers/';    for ( var i=0; i<images.length; i++)   {     if (images[i].id.match(roll))     {       currentRoll = images[i].id;       preload[i] = new Image();       preload[i].src = images[i].id + '_over.gif';       images[i].onmouseover = function()        {          var button = this.id;         this.src = fileLoc + this.id + '_over.gif';          for ( var i=0; i<images.length; i++)         {           if (images[i].id.match(header))           {             var temp = images[i].id;             if (images[i].id == '_' + this.id + '_header')             {               images[i].src = fileLoc + this.id + '_header.gif';               images[i].style.visibility='visible';               images[i].onmouseover = function()                {                   for ( var i=0; i<images.length; i++)                   {                     if (images[i].id.match(text))                     {                       var temp = images[i].id;                       images[i].src = fileLoc + this.id + '_text.gif';                       images[i].style.visibility='visible';                       break;                      }                   }                 }               break;             }             else             {               images[i].src = fileLoc + this.id + '_header.gif';               images[i].setAttribute('id',                images[i].style.visibility='visible';               images[i].onmouseover = function()                {                 for ( var i=0; i<images.length; i++)                 {                   if (images[i].id.match(text))                   {                     var temp = images[i].id;                     images[i].src = fileLoc + this.id + '_text.gif';                     images[i].style.visibility='visible';                     break;                    }                 }                 }               break;             }           }         }         images[i].onmouseout = function()          {            this.src = fileLoc + this.id + '_org.gif';            for ( var i=0; i<images.length; i++)           {             if (images[i].id.match(header))             {                images[i].style.visibility='hidden'             }           }           }       }       }      else if (images[i].id.match(simple))     {       preload[i] = new Image();       preload[i].src = images[i].id + '_over.gif';       images[i].onmouseover = function()        {         this.src = fileLoc + this.id + '_over.gif';         }       images[i].onmouseout = function()       {         this.src = fileLoc + this.id + '_org.gif';       }     }   } }  window.onload = rollover; 
  • 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. 2026-05-10T22:56:08+00:00Added an answer on May 10, 2026 at 10:56 pm

    Cripes..

    You should look into using jQuery.

    For example..

    $(     function() {         $('img.rollover').hover(             function() {                 this.src = this.src.replace('_org','_over');             },             function() {                 this.src = this.src.replace('_over','_org');             }         );     } ) 

    Inside the functions you can also play around with the visibility and do whatever else you want.

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

Sidebar

Ask A Question

Stats

  • Questions 171k
  • Answers 171k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Sounds like your main window doesn't always get the focus… May 12, 2026 at 2:17 pm
  • Editorial Team
    Editorial Team added an answer If you're program requires .net Framework 3.5, then the installer… May 12, 2026 at 2:17 pm
  • Editorial Team
    Editorial Team added an answer I don't have a good overview of solutions because I… May 12, 2026 at 2:17 pm

Related Questions

My question is how to get the number of rows returned by a query
I am using a multi-dimensional dynamic array in delphi and am trying to figure
I am trying to determine what the best way is to find variations of
I am writing some small program in C--some log in, log out, create account,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.