[英]How do I add timing event to an event listener
I need to delay this by 3 seconds...我需要延迟 3 秒...
document.addEventListener("DOMContentLoaded", function(event) {
var x = VarPagesInChapter.getValue();
var y = Var_visitedPageCount.getValue();
var progress = Math.round(y/x*100);
document.getElementById('pct').innerHTML = progress+'%';
document.getElementById('radial').classList.add('p'+progress);
});
You need the setTimeout()
function:您需要
setTimeout()
函数:
document.addEventListener("DOMContentLoaded", function(event) { console.log( "Loaded at " + performance.now() ); setTimeout(function() { //Your code console.log( "I'm ready at " + performance.now() ); }, 3000); // 3000 milliseconds = 3 sec });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.