• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

How to substitute a text name for an ID, in place of a variable name, in JavaScript

Hello,

In the below JavaScript line, "regionList" is a variable that comes from an ImageMap ID, during the mouseover event.  What is the syntax if I want to specify the actaul text value as opposed to using the variable?

jQuery(regionList).css('display', 'none');

Thank you!
Riverwalk
0
RiverWalk
Asked:
RiverWalk
  • 4
  • 2
1 Solution
 
zappafan2k2Commented:
If the variable regionList applies to the id, then it would simply be
jQuery('#idOfImageMap').css('display','none');

The '#' will select an element with the id of whatever text follows it.
0
 
RiverWalkAuthor Commented:
Thanks for responding.

In this case it is referencing the class of a <ul> tag, like this,  <ul class="ImageMap-list2"> .  How would I do that?


Thank you,
Riverwalk
0
 
leakim971PluritechnicianCommented:
jQuery("." + $(this).text()).css('display', 'none'); // class + current text
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
RiverWalkAuthor Commented:
Thanks leakim971. And sorry to be so illiterate, but where do I type in the actual text?  I want to type in, for example, "ImageMap-list2". Where does that go?  

Thanks,
Riverwalk
0
 
RiverWalkAuthor Commented:
I typed it into the .text(ImageMap-List2)  but I am getting an error stating that "List2" is undefined.  

I am trying to hide the below content in the <ul> tag. This works somewhat using variables but now I need to hide this one by specifying the text name of the class.


<div id="practice-container2">
      <div id="QuickNav-1">
                  <ul class="ImageMap-list2">
                        <div>
                              <b>xxxxxxx</b> <br />
                              WHAT WHAT WHAT WHAT WHAT WHAT WHAT WHAT WHAT WHAT WHAT WHAT <br />
                              This will be default data, which will be here when
                              the page loads but go away when an image map link is hovered
                              or clicked.
                        </div>
                  </ul>  
      </div>
      </div>
0
 
leakim971PluritechnicianCommented:
$(".ImageMap-list2").hide();
0
 
RiverWalkAuthor Commented:
Thank you!!!!!!!!!! You are one smart person to wade through my nonsense!!!


Riverwalk
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now