I've got the following code:
var clicked = false;
var klick = false;
$("img#hovertom").click(function() {
if (clicked) clicked = true;
else $(this).attr("src", "../img/tom_effects.png");
if (clicked = true) $(this).attr("src", "../img/tom_effects.png");
if (clicked = true) $("img#hoverdaniel").attr("src", "../img/daniel.png");
if (clicked = true) klick = false;
});
$("img#hovertom").hover(function() {
if (!clicked) $(this).attr("src", "../img/tom_hover.png");
}, function() {
if (!clicked) $(this).attr("src", "../img/tom.png");
});
$("img#hoverdaniel").click(function() {
if (klick) klick = true;
else $(this).attr("src", "../img/daniel_effects.png");
if (klick = true) $(this).attr("src", "../img/daniel_effects.png");
if (klick = true) $("img#hovertom").attr("src", "../img/tom.png");
if (klick = true) clicked = false;
});
$("img#hoverdaniel").hover(function() {
if (!klick) $(this).attr("src", "../img/daniel_hover.png");
}, function() {
if (!klick) $(this).attr("src", "../img/daniel.png");
});
There are 2 images with each 3 versions, they change on hover and click. And if you click the other image. It works fine, but the image changes immediately. Can anyone rewrite the code that the images fadein fadeout or fadeto, simply that the images are 'animated' when they change.
Thx