2013-01-12 59 views
0

我这个代码有问题 当我点击下一页>>>一个页面刷新两次。 < < < 它可能停止?对不起,我的英文不好jquery页面切换器

代码

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

回答

1

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 
}); 
+0

感谢这么mutch罗伯特。 – Live

+0

不客气:)请接受答案。 – robertklep