Reputation: 3117
I use slideToggle to open and hide div as you see below.
$(document).ready(function(){
$('.btnopencart').click(function() {
$('#shoppingCart').slideToggle( "fast", function() {
});
});
});
But I want to set 5s for display #shoppingCart and of course it can toggle again although it is 'display:none' or 'display:block'
Thank you very much.
Upvotes: 2
Views: 297
Reputation: 167172
Use .delay()
and $(this)
:
$(document).ready(function(){
$('.btnopencart').click(function() {
$('#shoppingCart').slideToggle( "fast", function() {
$(this).delay(5000).slideToggle("fast");
});
});
});
Upvotes: 4