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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:09:40+00:00 2026-05-31T07:09:40+00:00

I have multiple image maps on one page, and it’s a requirement to setup

  • 0

I have multiple image maps on one page, and it’s a requirement to setup arrays to feed their title attribute for Google Analytics.

Although this works, it doesn’t seem the right way to do it. I’m learning jQuery and hoping to learn from my mistakes and the correct way to write the code.

HTML:

<img src="map1.jpg" width="100" height="10" border="0" usemap="#Map1" />
<map name="Map1" id="Map1">
  <area shape="rect" coords="609,235,834,335" href="testa.htm" class="fancybox" rel="iframe"/>
  <area shape="rect" coords="609,235,834,335" href="testb.htm" class="fancybox" rel="iframe"/>
  <area shape="rect" coords="609,235,834,335" href="testc.htm" class="fancybox" rel="iframe"/>
  <area shape="rect" coords="609,235,834,335" href="testd.htm" class="fancybox" rel="iframe"/>
</map>

<img src="map2.jpg" width="100" height="10" border="0" usemap="#Map2" />
<map name="Map2" id="Map2">
  <area shape="rect" coords="609,235,834,335" href="testa.htm" class="fancybox" rel="iframe"/>
  <area shape="rect" coords="609,235,834,335" href="testb.htm" class="fancybox" rel="iframe"/>
  <area shape="rect" coords="609,235,834,335" href="testc.htm" class="fancybox" rel="iframe"/>
  <area shape="rect" coords="609,235,834,335" href="testd.htm" class="fancybox" rel="iframe"/>
</map>

<img src="map3.jpg" width="100" height="10" border="0" usemap="#Map3" />
<map name="Map3" id="Map3">
  <area shape="rect" coords="609,235,834,335" href="testa.htm" class="fancybox" rel="iframe"/>
  <area shape="rect" coords="609,235,834,335" href="testb.htm" class="fancybox" rel="iframe"/>
  <area shape="rect" coords="609,235,834,335" href="testc.htm" class="fancybox" rel="iframe"/>
  <area shape="rect" coords="609,235,834,335" href="testd.htm" class="fancybox" rel="iframe"/>
</map>

<img src="map4.jpg" width="100" height="10" border="0" usemap="#Map4" />
<map name="Map4" id="Map4">
  <area shape="rect" coords="609,235,834,335" href="testa.htm" class="fancybox" rel="iframe"/>
  <area shape="rect" coords="609,235,834,335" href="testb.htm" class="fancybox" rel="iframe"/>
  <area shape="rect" coords="609,235,834,335" href="testc.htm" class="fancybox" rel="iframe"/>
  <area shape="rect" coords="609,235,834,335" href="testd.htm" class="fancybox" rel="iframe"/>
</map>

jQuery:

> var map1array = [ "test a",
>                   "test b",
>                   "test c",
>                   "test d"
>                  ]; 
> 
> var map2array = [ "test a2",
>                   "test b2",
>                   "test c2",
>                   "test d2"
>                 ]; 
> 
> var map3array = [ "test a3",
>                   "test b3",
>                   "test c3",
>                   "test d3"
>                 ]; 
> 
> var map4array = [ "test a4",
>                   "test b4",
>                   "test c4",
>                   "test d4"
>                 ]; 
    $('#Map1 > area').click(function(e) {$(this).attr('title', map1array[$(this).index()]);});
    $('#Map2 > area').click(function(e) {$(this).attr('title', map2array[$(this).index()]);});    
    $('#Map3 > area').click(function(e) {$(this).attr('title', map3array[$(this).index()]);});
    $('#Map4 > area').click(function(e) {$(this).attr('title', map4array[$(this).index()]);});  ​

​

  • 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-31T07:09:41+00:00Added an answer on May 31, 2026 at 7:09 am

    Use a for loop, and change map1array to be:

    var map1array = [ "test a0",
                      "test b0",
                      "test c0",
                      "test d0"
                     ];
    

    Hint: iterate over a number from 0 to 3 (inclusive).

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

Sidebar

Related Questions

I have successfully implemented code to plot multiple locations on google maps dynamically. Solution:
I have this requirement, A product can have multiple images and only one default
I have a map with multiple markers of companies using google maps API v3.
I have multiple DIVs containing an image in each. When I rollover these DIVs,
I have an image sprite of sorts with multiple frames for 1 button. I'm
I have multiple images that have the same class attribute and I want to
I have multiple selects: <select id=one> <option value=1>one</option> <option value=2>two</option> <option value=3>three</option> </select> <select
I have multiple image galleries that use the following code (simply view the demo
I have multiple images and want to find out if each image horizontal or
I have a tabcontrol used to display multiple image files in an application. I

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.