Redirection on the last Slideshow-Element with Jquery

Posted by Agssl on Stack Overflow See other posts from Stack Overflow or by Agssl
Published on 2010-03-15T08:27:41Z Indexed on 2010/03/15 8:29 UTC
Read the original article Hit count: 413

Filed under:
|
|

Hi,

I'm very new to Jquery and want to realize a manual slideshow with a page-redirect on the last "next"-button.

I detect the last Slide-Element with CSS-Classes and then I want to add a Class to the next button to declare that it is the last next-button of the whole Slideshow.

The half of my Code works :) – If I navigate to the last Slide-Element, Jquery adds the Class "last" to the button and if I click on the button with this Class, I'm redirected to the next page – that's what I want. But if I navigate to the last Slide-Element, then click a few times the "prev"-button and then again the next button, I'm instantly redirected although the Class "last" was removed.

Thanks in advance and sorry for my bad english.

Here's my Code:


$(document).ready(function(){   

$("#image_nav a:first").attr('id', 'firstSlide'); $("#image_nav a:last").attr('id', 'lastSlide');

$(".dritte_ebene li:first").attr('id', 'firstNavi'); $(".dritte_ebene li:last").attr('id', 'lastNavi');

//Redirect to the next page $("a").click(function(){
if ($("#lastSlide").hasClass("activeSlide")) { $("#weiter").addClass("last"); $('.slide').cycle('pause'); $(".last").click(function(){
window.location.replace("[+PJN_next+]");
}); } });

//Remove "last" if prev is clicked $('#zurueck').click(function(){
$("#weiter").removeClass("last"); });

});

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about redirect