In your live demo currently you've left out the highlighted line:
Code:
$(document).ready(function(){
$('#thumbs ul li a').hover(
function() {
var currentBigImage = $('#bigpic img').attr('src');
var newBigImage = $(this).attr('title');
var currentThumbSrc = $(this).attr('rel');
var currentHref = $(this).attr('href');
switchImage(newBigImage, currentBigImage, currentThumbSrc, currentHref);
},
function() {}
);
function switchImage(imageHref, currentBigImage, currentThumbSrc, currentHref) {
var theBigImage = $('#bigpic img');
if (imageHref != currentBigImage) {
$('#bigpic a').attr('href', currentHref);
theBigImage.fadeOut(0 , function(){
theBigImage.attr('src', imageHref).fadeIn(0);
var newImageDesc = $("#thumbs ul li a img[src='"+currentThumbSrc+"']").attr('alt');
$('p#desc').empty().html(newImageDesc);
});
}
}
});
As a result the big image never changes and when hovering the trigger for the first one:
Code:
if (imageHref != currentBigImage) {
is never true. Reinstating the missing line should do the trick.
By the way, in an unrelated matter:
Code:
$('#thumbs ul li a').mouseenter(
function() {
var currentBigImage = $('#bigpic img').attr('src');
var newBigImage = $(this).attr('title');
var currentThumbSrc = $(this).attr('rel');
var currentHref = $(this).attr('href');
switchImage(newBigImage, currentBigImage, currentThumbSrc, currentHref);
}
);
is the same as:
Code:
$('#thumbs ul li a').hover(
function() {
var currentBigImage = $('#bigpic img').attr('src');
var newBigImage = $(this).attr('title');
var currentThumbSrc = $(this).attr('rel');
var currentHref = $(this).attr('href');
switchImage(newBigImage, currentBigImage, currentThumbSrc, currentHref);
},
function() {}
);
without the need of the empty function.
Bookmarks