如何让 jQuery 函数在新页面重新加载之前完成执行?这是我的代码:
$(document).ready(function(){
$("#box1").click(function(){
var div=$("#box1");
div.animate({left:'-=500px'},"slow").hide(1000, null);
var div=$("#box2");
div.animate({left:'-=1000px'},"slow").hide(1000);
});
});
$(document).ready(function(){
$("#box2").click(function(){
var div=$("#box2");
div.animate({left:'+=500px'},"slow").hide(1000);
var div=$("#box1");
div.animate({left:'+=1000px'},"slow").hide(1000);
});
});
这两个框是指向新页面的链接,如果新页面加载得非常快,则该功能被切断。现在,我知道可以放入的回调函数,hide()
但是我可以让该函数做什么,这不会影响任何事情?
编辑:
<body>
<a href = "Profile/profile.php">
<div id = "box1" style = "background-color: #98bf21;" >
<center>
<div style= "border: 125px solid #98bf21; background-color: #98bf21;">
Box1
</div>
</center>
</div>
<a href = "KC_Choir/index.php">
<div id = "Box2" style = "background-color: #98bf21;" >
<center>
<div style= "border: 125px solid #98bf21;">
Box2
</div>
</center>
</div>
</body>