We help IT Professionals succeed at work.
Get Started

show and hide JS/CSS

Refael
Refael asked
on
196 Views
Last Modified: 2012-08-14
Hello experts,

I have an image of a house with hotspots links. Each hotspot should hide the initial house image and show the relevant image depending on the hotspot.

Here is the code:
<div id="house_container">

<div id="house"><img src="house.gif" usemap="#Map" /></div>
<div id="house35" style="visibility:hidden;"><img src="35.gif" usemap="#Map" /></div>
<div id="house27" style="visibility:hidden;"><img src="27.gif" usemap="#Map" /></div>

<map name="Map" id="Map">

<area shape="rect" alt="" coords="102,51,135,83" href="#" onmouseover="Hide('house'); Show('house35');" onmouseout="Hide('house35'); Show('house'); " />
<area shape="rect" alt="" coords="63,92,99,123" href="#" onmouseover="Hide('house'); Show('house27');" onmouseout="Hide('house27'); Show('house'); " />

</map>
</div>


---------------------------------------------
below is the JS code the page uses:

function Show(id) {
   obj = document.getElementsByTagName("div");
   if (obj[id].style.visibility == 'hidden'){
   	obj[id].style.visibility = 'visible';
   }
   
   if (obj[id].style.display == 'none'){
   	obj[id].style.display = 'block';
   }
}

function Hide(id) {
    obj = document.getElementsByTagName("div");
    if (obj[id].style.visibility == 'visible'){
    	obj[id].style.visibility = 'hidden';
    }
    
    if (obj[id].style.display == 'block'){
   		obj[id].style.display = 'none';
   	}
}
----------------------------------------------------

Open in new window


"house 35" is showing in the right place (replacing the initial image but "house27"  (the 2nd image) is showing down below the initial house.

How can I get "house27" to show where the initial image is like the initial image and "house35" is positioned?
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE