用JS写一个极简的番茄钟

 
  
把这三行代码贴到FF/Chrome浏览器的console里边就好了。有兴趣的同学可以让它变得强大一些。 total = 25 ;
myClock = setInterval ( function () { total = total - 1 ; console . log ( "Remaining " + total + " mins" ); if ( total === 0 ) { cancelClock (); alert ( "Done" ); }}, 1000 * 60 );
cancelClock = function () { clearInterval ( myClock ); }


代码段同时也放在这里了: https://code.csdn.net/snippets/692668



猜你喜欢

转载自blog.csdn.net/idisposable/article/details/46469993