关于javascript:在setTimeout里设置倒数5秒计时的方法





当显示弹窗three-method时开始倒计时5秒

$('.three-method').show()
    var countdown = 5;
    setTimeout(function () {
        window.clearInterval(timer);
        window.open("http://192.168.10.125:10096/guan/download", "_parent");
    }, 5000); 
    timer = setInterval(() => { 
         var i18nText = $("#regCountdown").text();//获取“你已胜利主册,2秒後跳溥至APP下戴页”
         i18nText = i18nText.replace(countdown,--countdown);//replace()在字符串中用“countdown=5”的字符替换递加后的countdown的值
         $("#regCountdown").text(i18nText);
    }, 1000);//每一秒执行一次

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理