1
我是一名JavaScript初學者,爲web應用程序編寫js代碼,但一度陷入困境。如何在定時器耗盡後打開模式彈出?
我有一個定時器的網頁5秒,並在計時器用完後,我期望一個模式彈出。
我寫的代碼here:
var count=-1; // initially -1 as we are having a delay of 1000ms
var counter=setInterval(timer, 1000); //1000 will run it every 1 second
function timer()
{
count=count+1;
if (count >=6) //+1 than the req time as we have a delay of 1000ms
{
clearInterval(counter);
/////////////what code should go here for the modal to pop up??///////////////////////
return;
}
document.getElementById("timer").innerHTML=count + " secs"; // watch for spelling
}
我只是想知道的代碼,使彈出的時間用完之後。
在你的例子中你使用引導? 你可以使用bootstrap模態插件: [link] http://www.w3schools.com/bootstrap/bootstrap_modal.asp –