gpt4 book ai didi

javascript - 在间隔中使用 jQuery Glow

转载 作者:行者123 更新时间:2023-11-30 18:29:49 24 4
gpt4 key购买 nike

我想使用 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);
});

我该怎么做?

谢谢

最佳答案

虽然我不喜欢在插件不提供 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));

关于javascript - 在间隔中使用 jQuery Glow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9974449/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com