需要jQuery闪烁文本仅闪烁8秒,然后停止 [英] Need jquery blinking text to only blink for a period of 8 seconds, then stop
本文介绍了需要jQuery闪烁文本仅闪烁8秒,然后停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在8秒钟后停止闪烁文本.除了能够在8秒钟后将其停止之外,其他所有功能均正常运行.我对此很陌生,需要帮助...
I need to stop flashing text after 8 seconds. Everything is working perfectly except being able to stop it after the 8 seconds. I am new to this, need help...
这是我正在使用的代码,请提出建议或在此代码中添加8秒后停止运行所需的内容:
Here is code that I am using, please give suggestions or add to this code what I need for it to stop after 8 seconds :
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
<div id="msg"> <strong><font color="red">text example</font></strong></p> </div>
<script type="text/javascript" >
function blink(selector){
$(selector).fadeOut('slow', function(){
$(this).fadeIn('slow', function(){
blink(this);
});
});
}
blink('#msg');
</script>
谢谢
推荐答案
您可以尝试对代码进行这样的添加:
You can try such an addition to your code:
var stopBlinking = false;
setTimeout(function()
{
stopBlinking = true;
}, 8000);
function blink(selector) {
$(selector).fadeOut('slow', function() {
$(this).fadeIn('slow', function() {
if (!stopBlinking)
{
blink(this);
}
else
{
$(this).hide();
}
});
});
}
请参见示例此处
这篇关于需要jQuery闪烁文本仅闪烁8秒,然后停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文