Sunday, February 1, 2009

[jQuery] Re: Clickable slideshow not working as expected.

When do you call the hover-function? On $(document).ready? To me it
looks like the hover won't work because it is never applied to the
next photo (as it isn't a current-class when loaded). Maybe it should
go like this:

function addMyFunctionality() {
$('.current img.after').hover(
function() {
$(this).animate({opacity: "0"});
},
function() {
$(this).animate({opacity: "1"});
}

$('.current').click(function() {
$(this).removeClass('current').addClass
('invisible');
$(this).next('div').removeClass
('invisible').addClass('current');
addMyFunctionality();
});

No comments: