I have a problem with this code when I click on the next page>>>a page refresh two times.<<< Its possible to stop? sorry for my poor english

Code

jQuery(document).ready(function() {

$(".container").css("display", "none");

$(".container").fadeIn(1000);

$("a.pager").click(function(event){
    event.preventDefault();
    linkLocation = this.href;
    jQuery(".container").fadeOut(1000, redirectPage);       
});

function redirectPage() {
    window.location = linkLocation;
}});

Thanks very much

有帮助吗?

解决方案

You need to stop propagation of the click event (which is different from .preventDefault()):

$("a.pager").click(function(event){
  event.preventDefault();
  linkLocation = this.href;
  jQuery(".container").fadeOut(1000, redirectPage);
  return false; // stop propagation of the click event 
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top