我使用以下脚本关闭联系人面板:
<script type="text/javascript">
$(document).ready(function(){
$("#home").click(function(){
$("#panel").slideUp("slow");
$(this).toggleClass("top-current");
$(this).toggleClass("top");
$("#contact").toggleClass("top-current");
$("#contact").toggleClass("top");
return false;
});
});
</script>
由于我在不同页面上使用相同的脚本,如果用户位于主页以外的页面上,那么我需要在脚本中添加更多内容,以便在面板之后加载主页(index.html)已关闭。所以我想我需要延迟然后加载index.html页面,但我不知道如何在jQuery中执行此操作,并且会感激一些帮助。
谢谢,
尼克
答案 0 :(得分:3)
我认为当你说你需要添加延迟时,你的意思是你要等到滑动动画结束。您可以为slideUp
方法提供回调函数,该函数将在动画完成时运行。在该回调中,您可以将用户发送到您的主页:
$("#panel").slideUp("slow", function() {
window.location = "index.html";
});