【问题标题】:using jQuery Glow in Intervals在间隔中使用 jQuery Glow
【发布时间】:2012-04-02 10:08:09
【问题描述】:

我想在我的页面中使用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);
    }); 

我该怎么做?

谢谢

【问题讨论】:

  • 您希望它在悬停时开始闪烁,对吧?
  • 不,我希望它自动启动

标签: javascript jquery asp.net jquery-plugins


【解决方案1】:

虽然我不喜欢在插件不提供 api 的情况下伪造效果(这意味着在 jquery-glow 插件中无法触发发光),但这是一个可能的解决方案:

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));

【讨论】:

    猜你喜欢
    • 2011-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多