Reputation: 2959
I have the following function which fade out the div on touch but I want in the same time to make it disappear after 5 seconds in case the user will not react. Any idea how shall I modify the code?
$('#ceva').on({
'touchstart': function() {
$('#ceva').fadeOut();
}
});
Upvotes: 0
Views: 63
Reputation: 87203
Use delay
with touchend
as follow.
Set a timer to delay execution of subsequent items in the queue.
$('#ceva').on({
'touchstart': function() {
$('#ceva').fadeOut();
}
});
In ready
add following:
$('#ceva').delay(5000).fadeOut();
Upvotes: 2
Reputation: 541
Please try this.
$(function() {
setTimeout(function() {
$("#ceva").hide('blind', {}, 500)
}, 5000);
});
Upvotes: 0