var counter = 5;
var timer = setInterval(function () {
seconds--;
$('#regmsg').html('Successful! Message will close in ' + counter);
if (counter == 0) {
$.fancybox.close();
parent.location.reload();
}
}, 1000);
$.fancybox({
href: '#regmsg',
type: 'inline',
'closeBtn': false
});
我希望时间显示在#regmsg
,但它只显示'成功!'而不是消息的其余部分。问题是什么?我该如何解决?
答案 0 :(得分:0)
将seconds
更改为counter
。
var counter = 5;
var timer = setInterval(function () {
counter--; // <- here
$('#regmsg').html('Successful! Message will close in ' + counter);
if (counter == 0) {
$.fancybox.close();
parent.location.reload();
}
}, 1000);