views:

157

answers:

1

I need to fade a div (and image) to reveal a div underneath (text with clickable links) using jQuery.

<script>
$(document).ready(function(){
$("img.a").hover(
function() {
$(this).stop().animate({"opacity": "0"}, "slow");
},
function() {
$(this).stop().animate({"opacity": "1"}, "slow");
});

});
</script>

Used the above code and all worked well, until I went to click the links. Seems the top hidden div is preventing me from doing so.

Tried the replaceWith function and that allowed me to click the links too - but couldn't get it to go back to showing original div when I moused out. Also, bossman wants the transition to be gradual - like a fade...

Any suggestions?

Many thanks!

Heath

A: 

Okay - both of the following are working well enough in most browsers, but in IE, whenever I even move the mouse slightly, the div starts fading in and out - and also can build up a queue or a loop of the fadein/fadeout events:

$(document).ready(function () {
$("#goingimg").hover(
function () {
$(".going").fadeOut("normal",0);
}, 
function () {
$(".going").fadeTo("normal",1);
}
);       
});


$(document).ready(function () {
$("#goingimg").hoverIntent(function() {
$(".gone").fadeOut("normal",0);
$('#goingimg').hoverIntent(function(event) { event.stopPropagation(); });
}, function() {
$(".gone").fadeTo("normal",1);
$('#goingimg').hoverIntent(function(event) { event.stopPropagation(); });

}); });

I tried the suggested hoverIntent plugin, and the event.stopPropagation function. Still, in IE - things are just all screwy. Is there any way around this that anyone knows of?

Many thanks...

Heath Waller