javascript - 停止jquery褪色效果?
问题描述
我正在尝试制作闪烁的灯光录制效果。这是我到目前为止的代码:
$("#stop").hide();
function blink() {
$("#red").fadeOut(500);
$("#red").fadeIn(500);
}
$("#start").click(function () {
$("#start").hide();
$("#stop").show();
window.test = setInterval(blink, 500);
});
$("#stop").click(function () {
window.clearInterval(test);
$("#stop").hide();
$("#start").show();
});
<button class="success" id="start">Start</button>
<button id="stop">Stop</button>
这是闪烁的灯光图像:
<img src="record.png" id="red" />
.stop();
。但它没有用。我怎样才能解决这个问题?提前感谢您的所有帮助!
解决方案
尝试:
function blink() {
$("#red").fadeOut(500);
$("#red").fadeIn(500);
}
$("#start").click(function () {
$("#start").hide();
$("#stop").show();
window.test = setInterval(blink, 500);
});
$("#stop").click(function () {
window.clearInterval(test);
$("#stop").stop();
$("#start").show();
});
它应该在当前间隔后停止亮灯。
推荐阅读
- javascript - 在 JavaScript 中分离 while 循环输出
- postgresql - 使用 PostgreSQL 创建数据透视表
- javascript - 如何在谷歌 AMP 中嵌入 Tawk 聊天脚本
- sql - 用于计算总计而不考虑重复行的 SQL 查询
- java - 通过 Retrofit 中的 Model 类在 GET 请求 URL 中传递 ID
- android - Android Studio 自动完成将对象包装在另一个对象中
- java - 在Java中将字节转换为兆字节变为零
- sql-server - 将 SSAS 数据库从 MSSQL 2005 迁移到 2012
- hibernate - 在grails的单个应用程序中连接不同的数据库(动态)
- oracle - 在子查询中使用全局临时表给出 NULL