[英]Stop jquery fading effect?
I am trying to make a blinking light recording effect.我正在尝试制作闪烁的灯光录制效果。 Here is the code I have so far:这是我到目前为止的代码:
$("#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>
Here is the blinking light image:这是闪烁的灯光图像:
<img src="record.png" id="red" />
.stop();
我也尝试使用 jquery: .stop();
.
.
But it did not work.
但它没有用。
How can I fix this?
我怎样才能解决这个问题?
Thanks for all your help in advance!
提前感谢您的所有帮助!
Try:尝试:
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();
});
It should stop the light after the current interval.它应该在当前间隔后停止灯光。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.