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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:57:58+00:00 2026-05-15T14:57:58+00:00

(Edited with more detail just in case someone else has a similar question) I’ve

  • 0

(Edited with more detail just in case someone else has a similar question)

I’ve got an image map which needs to reveal a div on rollover of a hotspot. I’ve given my areas on the image map classes, and using jQuery want to reveal it’s corresponding div, e.g.,

area shape="rect" coords="601,31,723,107" href="#" alt="Some Location" class="some-location"

Each area has a different location and therefore different classname.

I’m not sure how to reference an element with its classname stored in a variable?
For example, the code I currently have to get the class name on hovering over an area on the image map is:


var hotspot = $(this).attr("class");

Now I want to do something like:


$(div.hotspot).show();

The above is not working – could someone point me in the right direction?

  • 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-15T14:57:59+00:00Added an answer on May 15, 2026 at 2:57 pm

    Use string concatenation:

    $("div." + hotspot)
    

    Obviously this only works if hotspot only contains one class (see Reigel’s comment). If it contains more classes, you have to replace the white spaces by a dot:

    $("div." + hotspot.replace(' ', '.'))
    

    (assuming that multiple white spaces between class names get trimmed automatically but I am not sure about that, otherwise you have to use the regular expression /\s+/)

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

Sidebar

Related Questions

NB: This question has been extensively edited to make it more relevant, for completeness
I edited the question so it would make more sense. I have a function
EDIT following resolution, this has been substantially edited to dump irrelevant detail and explain
Edited Question: This should be clear. using System; namespace UpdateDateTimeFields { class Program {
Edited: SOLUTION FOUND. This is strange and not the best solution, but I just
(Edited a lot) I've got some classes with Abstracts Members. The concrete type of
i have the WCF web service within my solution. service has interface which implemeted
I have such query (generated by Hibernate - edited for more clarity - below
I've got a query in similar structure to below SELECT blah FROM A, B,
Edited to add more details: (originally asked nearly two months ago...still haven't found a

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.