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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:04:33+00:00 2026-06-09T17:04:33+00:00

I have an image that I am using an image map on. When hovering

  • 0

I have an image that I am using an image map on. When hovering over part of the image depending on the map I want the image to change and I am not sure how to go about doing this using jQuery. Here is the code I have attempted:

HTML:

 <div class="img-center">
  <img src="img-src_off.jpg" usemap="#Map" class="feature-image" border="0" />
    <map name="Map" id="Map">
      <area shape="rect" coords="77,461,391,492" href="#" target="_blank"
            class="link-1" />
      <area shape="rect" coords="557,461,855,490" href="#" target="_blank" 
            class="link2" />
    </map>
 </div>

JS:

Note: This is the JS I have attempted but errors are thrown (errors listed below) and I do not know what to try now. I do not have to use this code if I can find a code that works without issue.

var $j = jQuery.noConflict();
  $j(document).ready(function() {
     $j.preLoadImages("img_src_01.jpg",
                     "img_src_02.jpg"
     ); 

     $j(".link1").hover(function(){
        this.src = this.src.replace("_off","_01");
        },
        function(){
        this.src = this.src.replace("_01","_off");
        }
     );

           $j(".link2").hover(function(){
        this.src = this.src.replace("_off","_02");
        },
        function(){
        this.src = this.src.replace("_02","_off");
        }
     ); 
   });

  (function(j$) {
    var cache = [];
    $j.preLoadImages = function() {
      var args_len = arguments.length;
      for (var i = args_len; i--;) {
        var cacheImage = document.createElement('img');
        cacheImage.src = arguments[i];
        cache.push(cacheImage);
      }
    }
  });

The errors I see are as follow:

TypeError: this.src is undefined
[Break On This Error]   

this.src = this.src.replace("_off","_01");

(this error repeats itself on every hover)

And this error:

TypeError: $j.preLoadImages is not a function
[Break On This Error]   

"img_src_02.jpg"

Please provide examples when answering as I am not very fluent in Javascript.

  • 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-09T17:04:34+00:00Added an answer on June 9, 2026 at 5:04 pm

    To write a jQuery plugin, start by adding a new function property to the jQuery.fn object where the name of the property is the name of your plugin:

    Try the following:

    (function($j) {
       $j.fn.preLoadImages = function() {
            //...
       }
    })(jQuery);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an image that I want to resize on my websites rendering using
I am using GWT 2.03 and am have an image that I want to
I have a 16 bit grayscale image that I want to display using WPF
I currently have a menu using hovering image maps that works in Firefox, IE,
I have a huge map image (25mb) that I want to use in my
I have a high-resolution image that I want to use as a tiled map
I want to have a map view that loads from an image that I
I have an image that is served as static file using Nginx, but I
I have a logo link that's using a background-image (css sprite). All works fine,
I am using a webview and on that web view i have a 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.