闪光文字三秒钟

der*_*hen 3 javascript css blink

我知道眨眼不是一件好事.然而...

我有一个很复杂的HTML表单,包含许多必填字段.除了突出显示空文本框,我想通过闪烁问题的文本大约三秒钟来引起他们的注意.

我可以找到的所有javascript/css方法似乎都会在有多个这样的项目闪烁时被忽略,或者是为了让项目一直闪烁而设计的.

有关如何实现这一目标的任何建议?

什么是网页中闪烁文本的替代方法看起来有点矫枉过正.

谢谢

德里克

我已经尝试了这个(闪烁每个指定的跨度超过三秒),但它只适用于它所要求的第一个项目:

function blinkOn(span){
    span.counter=0;
    span.defColor=span.style.color;
    span.alertTimerId =setInterval("blinkOnce('"+span.id+"')", 400 );
}

function blinkOnce(spanID){
    var span=document.getElementById(spanID)
    span.counter++;
    if(span.style.color==span.defColor){
        span.style.color='transparent'}
     else{
        span.style.color=span.defColor;
     }
    if(span.counter>8){
        blinkOff(span);
    }   
}

function blinkOff(span){
   clearInterval(span.alertTimerId);    
   span.style.color=span.defColor;
}
Run Code Online (Sandbox Code Playgroud)

Sco*_*own 10

我个人使用jQuery来做这种事情:

$('#element_id')
    .fadeOut(300)
    .fadeIn(300)
    .fadeOut(300)
    .fadeIn(300)
    .fadeOut(300)
    .fadeIn(300)
    .fadeOut(300)
    .fadeIn(300)
    .fadeOut(300)
    .fadeIn(300);
Run Code Online (Sandbox Code Playgroud)

相当不雅,我知道,但它做的工作.jQuery UI确实有一些更简洁的效果.

我使用它的唯一地方是当用户向购物篮添加内容而不重定向到购物篮页面时,只是为了确保他们知道它已被添加.

请参阅: http://api.jquery.com/fadeIn/,http://api.jquery.com/fadeOut/http://jqueryui.com/docs/show/(搏动,尤其是)

  • 不雅,粗暴,是的!但是,网页上的闪烁元素也是如此:-) (2认同)