title: Redirection on the last Slideshow-Element with Jquery
body: <p>I'm very new to Jquery and want to realize a manual slideshow with a page-redirect on the last "next"-button.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>Thanks in advance and sorry for my bad english.</p>
  
  <p>Here's my Code:</p>
  
  <pre><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");
  }); 
  
  
  }); 
  </code></pre>