几秒钟后如何隐藏Flash消息? [英] How to hide flash message after few seconds?
本文介绍了几秒钟后如何隐藏Flash消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,用户可以向其他用户发布挑战。因此,在成功发布挑战后,我将显示一条相同的即时消息。但是现在我想在几秒钟后隐藏此消息。所以我写了以下代码:
In my application user can post challenge for other user. So after successful posting a challenge I am displaying one flash message for the same. But now I want to hide this message after some few seconds. So I wrote following code :
$(document).ready(function(){
setTimeout(function() {
$("#successMessage").hide('blind', {}, 500)
}, 5000);
});
<div id="successMessage" style="text-align:center; width:100%">
<FONT color="green">
<%if flash[:alert]=="Your challenge is posted successfully."%>
<h4><%= flash[:alert] if flash[:alert].present? %>
<%end%>
</font>
</div>
但是此代码并未隐藏div successMessage。
But this code is not hiding the div "successMessage".
推荐答案
您可以尝试:
setTimeout(function() {
$('#successMessage').fadeOut('fast');
}, 30000); // <-- time in milliseconds
如果使用此格式,则div将在30点后隐藏第二,我也尝试过这个,对我有用。
If you used this then your div will be hide after 30 sec.I also tried this one and it worked for me.
这篇关于几秒钟后如何隐藏Flash消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文