制作倒计时有开始和暂停按钮用js完整代码实现 ?

制作倒计时有开始和暂停按钮用js完整代码实现 


慕雪6442864
浏览 997回答 3
3回答

翻阅古今

<p></p><input&nbsp;type="button"&nbsp;value="提交"&nbsp;onclick="test()"><script>&nbsp;&nbsp;var&nbsp;count&nbsp;=&nbsp;1800;&nbsp;&nbsp;var&nbsp;p&nbsp;=&nbsp;document.querySelector('p')&nbsp;&nbsp;var&nbsp;intervalId&nbsp;=&nbsp;window.setInterval(countDown,&nbsp;1000)&nbsp;&nbsp;&nbsp;function&nbsp;countDown()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;--count&nbsp;&nbsp;&nbsp;&nbsp;p.innerText&nbsp;=&nbsp;timeFormat()&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;function&nbsp;test()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;count&nbsp;+=&nbsp;60&nbsp;*&nbsp;60&nbsp;&nbsp;&nbsp;&nbsp;p.innerText&nbsp;=&nbsp;timeFormat()&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;var&nbsp;hour,&nbsp;minute,&nbsp;second&nbsp;&nbsp;var&nbsp;timeText;&nbsp;&nbsp;&nbsp;function&nbsp;timeFormat()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;hour&nbsp;=&nbsp;Math.floor(count&nbsp;/&nbsp;(60&nbsp;*&nbsp;60));&nbsp;&nbsp;&nbsp;&nbsp;minute&nbsp;=&nbsp;Math.floor(count&nbsp;/&nbsp;60)&nbsp;-&nbsp;(hour&nbsp;*&nbsp;60);&nbsp;&nbsp;&nbsp;&nbsp;second&nbsp;=&nbsp;Math.floor(count)&nbsp;-&nbsp;(hour&nbsp;*&nbsp;60&nbsp;*&nbsp;60)&nbsp;-&nbsp;(minute&nbsp;*&nbsp;60);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timeText&nbsp;=&nbsp;hour&nbsp;+&nbsp;':'&nbsp;+&nbsp;minute&nbsp;+&nbsp;':'&nbsp;+&nbsp;second&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;timeText&nbsp;&nbsp;}</script>

MM们

#include <stdio.h>#include <stdlib.h>#include <conio.h>#include <windows.h>void my_menu(void){system("cls");printf("界面\n");}void my_operate(void){printf("%c\n", getch());//注意:可以将输入值用数组等保存,这里没有保存}void my_time(void){int i;for (i=60; i>0; i--){Sleep(999);system("cls");printf("倒计时:%d\n", i);printf("\n请输入一个字符:");if (kbhit()){my_operate();}}my_menu();}int main(void){my_time();return 0;}
打开App,查看更多内容
随时随地看视频慕课网APP