mr curious
02-18-2011, 12:30 PM
Hi,
I've created a mouse over effect with javascript which fades out a top image to show the image underneath.
<style type="text/css" media="screen">
.js #animators { position: relative; height: 100px}
.js #animators div.container { position: absolute; left: 0; top: 0
</style>
<script type="text/javascript">
document.documentElement.className += " js"; // Add js class to the HTML element
$(function(){
var $containers = $("#animators > div").hide();
$('#show').show();
$('tr td a.c').each(function(i,el){
var idx = i;
$(this).click(function(e){
var $target = $containers.filter(':eq(' + idx + ')');
if($containers.filter(':visible').not($target).length){
$containers.filter(':visible').fadeOut();
}
$target.not(':visible').fadeIn();
e.preventDefault();
})
})
});
</script>
<div class="thumbnail" style="margin-top:5%; margin-right:2%;">
<div class="visible-image">
<img src="images/illustrationslabel.jpg" />
</div>
<div class="appearing-image"><img onclick='$("a.illustrations:first").trigger("click");' src="images/illustrations.jpg" />
</div>
</div>
In the code i've got an onclick function triggering fancybox which allows you to view the image clicked on.
The problem is that sometimes the mouse over function gets stuck in its fade out process and doesn't work anymore.
PLZ any help would be so awesome..
mc
I've created a mouse over effect with javascript which fades out a top image to show the image underneath.
<style type="text/css" media="screen">
.js #animators { position: relative; height: 100px}
.js #animators div.container { position: absolute; left: 0; top: 0
</style>
<script type="text/javascript">
document.documentElement.className += " js"; // Add js class to the HTML element
$(function(){
var $containers = $("#animators > div").hide();
$('#show').show();
$('tr td a.c').each(function(i,el){
var idx = i;
$(this).click(function(e){
var $target = $containers.filter(':eq(' + idx + ')');
if($containers.filter(':visible').not($target).length){
$containers.filter(':visible').fadeOut();
}
$target.not(':visible').fadeIn();
e.preventDefault();
})
})
});
</script>
<div class="thumbnail" style="margin-top:5%; margin-right:2%;">
<div class="visible-image">
<img src="images/illustrationslabel.jpg" />
</div>
<div class="appearing-image"><img onclick='$("a.illustrations:first").trigger("click");' src="images/illustrations.jpg" />
</div>
</div>
In the code i've got an onclick function triggering fancybox which allows you to view the image clicked on.
The problem is that sometimes the mouse over function gets stuck in its fade out process and doesn't work anymore.
PLZ any help would be so awesome..
mc