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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:51:39+00:00 2026-05-31T10:51:39+00:00

I have a repeated class of .fancybox contained within image maps. <map name=Map1 id=Map1>

  • 0

I have a repeated class of .fancybox contained within image maps.

<map name="Map1" id="Map1">
  <area shape="rect" coords="609,235,834,335" href="about.html" class="fancybox" rel="iframe" />
  <area shape="rect" coords="649,546,807,565" href="info.html" class="fancybox" rel="iframe" />
  <area shape="rect" coords="670,566,781,582" href="help.html" class="fancybox" rel="iframe" />
</map>

<map name="Map2" id="Map2">
   <area shape="rect" coords="609,235,834,335" href="contact.html" class="fancybox" rel="iframe" />
   <area shape="rect" coords="649,546,807,565" href="comments.html" class="fancybox" rel="iframe" />
</map>

I then have an array in jQuery where I want to add the Title attribute. I know it can added in the HTML, but I need it fed by this array clientside as the image maps are generated by the server side CMS that I can’t edit.

$(document).ready(function() {
    var mapDetails = [   
        //Map1   
        "About Page",
        "Information",
        "Get Help",
        //Map2
        "Contact Me",
        "Post Comments"
        ]; 

   $('.fancybox').each(function() {
    $(this).attr('title', mapDetails[$(this).index()]); 
   })
});

The problem I have is that on Map2 it starts from the beginning of the array again instead of carrying on in the array as the fourth .fancybox on the page. I’m assuming it’s because they have different parent elements. Can I take all the .fancybox elements, assign them the titles from the array and update the HTML with jQuery so that all the .fancybox classes on the page are assigned from the array in order they appear?

I have also tried using the ‘area’ selector with the same result:

   $('area').each(function() {
    $(this).attr('title', mapDetails[$(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-31T10:51:40+00:00Added an answer on May 31, 2026 at 10:51 am

    Since you’re calling index() without arguments, it returns the index of each element relative to its siblings. Therefore, that index will “reset” when going from one <map> element to another.

    You can use the index argument provided by each() instead:

    $(".fancybox").each(function(index) {
        $(this).attr("title", mapDetails[index]);
    });
    

    That way, the index will keep incrementing for each element and will not reset between maps.

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

Sidebar

Related Questions

I have a table of 3 columns: AuthorID (id can be repeated) JournalName (name
i have repeated data in Target class list new TargetClass{ TID=102, ID=2, Adress=afff, Zip=222},
Right, lets say I have these repeated divs. <div class=upcoming> <div class=roll style=display:none>Hidden</div> </div>
I have a solution where I'm repeating various class names within three different projects
Lets say I have defined a class in my CSS, with the class name
I have two models class Employer(models.Model): name = models.CharField(max_length=300, blank=False) id = models.IntegerField() status
I have a DAO class with many methods that have a lot of repeated
i have a div with the class 'userFeatureProductImage'. this div is repeated however occasionally
Possible Duplicate: Avoiding repeated constants in CSS I want to include a class within
I have this div inside a repeater, where i set the class, onmouseover and

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.