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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:43:51+00:00 2026-05-15T01:43:51+00:00

I have a small problem, but I’m a bit stumped. I am using the

  • 0

I have a small problem, but I’m a bit stumped.

I am using the following code to do rollovers on my webpage

$("#mylink1 img").hover(
 function()
 {
  this.src = this.src.replace("_off","_on");
 },
 function()
 {
  this.src = this.src.replace("_on","_off");
 }
);

This works great for individual images, but I would like to roll over one of them and have the the other one change as well.

<a id="mylink1" href="about.cfm"><img src="images/Home_top_navs/aboutus_manage_off.gif" /></a>

<a id="mylink1" href="about.cfm"><img src="images/Home_top_navs/aboutus_nav2_off.gif" /></a>

Any help would be appreciated! Thank you!

  • 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-15T01:43:52+00:00Added an answer on May 15, 2026 at 1:43 am

    Change id to string @corroded suggested. IDs should be unique within a page.

    As for changing multiple images when hovering over a single image, you have to modify the hover over and out functions. Currently, they are only changing the src attribute of the image currently hovered over. Instead, inside both the functions, you have to loop through each image and change the src attribute. Something like:

    $("#mylink1 img").hover(
        function() {
            $(".mylink1 img").each(function() {
                this.src = this.src.replace("_off","_on");
            });
        },
        function() {
            $(".mylink1 img").each(function() {
                this.src = this.src.replace("_on","_off");
            });
        }
    );
    

    You can avoid the duplication with some currying:

    (function() {
        var images = $(".mylink1 img");
    
        function imageSwapper(imgs, from, to) {
            return function() {
                imgs.each(function() {
                    this.src = this.src.replace(from, to);
                });
            };
        }
    
        $(images).hover(
            imageSwapper(images, "_off", "_on"),
            imageSwapper(images, "_on", "_off")
        );
    })();​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started using Eclipse but already I have a small problem. At first
I am generating new xml file using perl script but I have small problem,
I have a small problem with the UITableviewCell. i'm using the code: UIView *cellBackView
I am using Jquery Autocomplete . Its workng fine but I have small problem.
I have a small problem i'm using this code to start counting from 20
i have a small problem here which i cannot fix,This post goes through but
Just a newbie with iPhone development.. I just have a small problem but huge
I would like to write to a text file, but I have small problem.
I have small problem with simple code. This code is working properly on x86
I have a small problem :) I was searching the web but didn't find

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.