Reputation: 4462
I am using the following script to close a contact panel:
<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>
As I am using the same script on different pages, if the user is on a page other than the home page then I need to add more to the script so that the home page is loaded (index.html) after the panel has closed. So I guess I would need a delay and then the index.html page to load, but I am not sure how to do this in jQuery, and would be grateful for some help.
Thanks,
Nick
Upvotes: 0
Views: 147
Reputation: 165951
I assume that when you say you need to add a delay, what you mean is that you want to wait until the sliding animation has finished. You can provide a callback function to the slideUp
method which will run when the animation is complete. In that callback, you can send the user to your home page:
$("#panel").slideUp("slow", function() {
window.location = "index.html";
});
Upvotes: 3