2012-04-02 23 views
1

使用jQuery夜光我想在我的頁面中使用this jquery glow plugin(DEMO)在間隔

我希望我的文字每4秒閃爍一次。我寫這段代碼,但它不起作用。

$(document).ready(function() { 
     $('.white').addGlow({ textColor: 'white', haloColor: '#aaa', radius: 100 }); 
     setInterval(function() { 
      $('.white').mouseenter(); 
      setTimeout(function() { }, 2000); 
      $('.white').mouseleave(); 
     }, 2000); 
    }); 

我該怎麼做?

感謝

+0

你想讓它開始眨眼,對吧? – 2012-04-02 10:21:38

+0

不,我希望它自動啓動 – Arian 2012-04-02 10:25:20

回答

2

雖然我沒有僞裝的效果,如果插件沒有提供它的API(意味着缺乏可能性引發了jQuery輝光插件輝光)的球迷,這裏是一個可能的解決方案:

http://jsfiddle.net/3LCdA/

(function loop() { 
    $('.green').mouseover(); 
    setTimeout(function() { 
    $('.green').mouseout(); 
    setTimeout(loop, 2000); 
    }, 2000); 
}()); 

或與參數:

http://jsfiddle.net/3LCdA/1/

(function loop(el, delay) { 
    el.mouseover(); 
    setTimeout(function() { 
    el.mouseout(); 
    setTimeout(function() { 
     loop(el, delay); 
    }, delay); 
    }, delay); 
}($('.green'), 2000));