|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I need to be able to make a hidden div appear when an image is hovered over or clicked on. I have no idea how to go about doing this. I've used codes for making images appear when something is hovered over, but I don't know if it's the same for an entire div. Is it possible to make a seperate html file for the object that needs to appear (instead of making it a hidden div), and include it the same way as an image?
I really need help :[ If anyone has any suggestions or resources, I'll appreciate it a lot (I'll draw you a picture of your dog or something!) |
|
#2
|
|||
|
|||
|
You just need to use the display style setting - set to 'none' (to hide) or 'block' (to show) as appropriate.
Here is a basic example using onClick assigned to a span element, obviously this can be an img or anyother element that supports onClick event. Code:
...
<script>
function showHide(id)
{
var current_state = document.getElementById(id).style.display;
if(current_state == "block")
{
document.getElementById(id).style.display = 'none';
}
else
{
document.getElementById(id).style.display = 'block';
}
}
</script>
<span onClick="showHide('show')" >Show/Hide</span>
<div id="show" style="display:none;">
Can you see me!?
</div>
...
__________________
"Badges? We ain't got no badges. We don't need to badges! I don't have to show you any stinkin' badges!!" |
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > REALLY need help: Making hidden div appear when an image is hovered/clicked |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|