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?
我有以下功能,淡出触摸div,但我希望在5秒后消失,以防用户不作出反应。知道如何修改代码?
$('#ceva').on({
'touchstart': function() {
$('#ceva').fadeOut();
}
});
2 个解决方案
#1
2
Use delay
with touchend
as follow.
使用延迟与touchend如下。
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();
#2
0
Please try this.
请试试这个。
$(function() {
setTimeout(function() {
$("#ceva").hide('blind', {}, 500)
}, 5000);
});
#1
2
Use delay
with touchend
as follow.
使用延迟与touchend如下。
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();
#2
0
Please try this.
请试试这个。
$(function() {
setTimeout(function() {
$("#ceva").hide('blind', {}, 500)
}, 5000);
});