I'm using javascript to hide an image and show some text thats hidden under it. But, when the text is shown if you scroll over it, it fires the mouseout event on the container, that then hides the text and shows the image again, and it just goes into a weird loop.
The html looks like this
<div onmouseover="jsHoverIn('1')" onmouseout="jsHoverOut('1')">
<div style="" id="image1" />
<div id="text1" style="display: none;">
<p>some content</p>
<p>some more content</p>
</div>
</div>
And the javascript ( It uses scriptaculous )
function jsHoverIn (id)
{
if ( !visible[id] )
{
new Effect.Fade ("image"+id, {queue: { position: 'end', scope: id } });
new Effect.Appear ("text"+id, {queue: { position: 'end', scope: id } });
visible[id] = true;
}
}
function jsHoverOut (id)
{
var scope = Effect.Queues.get( id );
scope.each( function( effect ){ effect.cancel() } );
new Effect.Fade ("text"+id, {queue: { position: 'end', scope: id } });
new Effect.Appear ("image"+id, {queue: { position: 'end', scope: id } });
visible[id] = false;
}
This seems really simple, but i just cant wrap my head around it.