Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div id="js-timetext">0.00</div>
<button id="js-btn--start">start</button>
<button id="js-btn--stop">stop</button>
<button id="js-btn--reset">reset</button>




  "use strict";//最近は厳密なエラーチェックをするのが推奨されている
  var startTime;//タイムを押した時の時刻を保持しておくため
  var timerId;//タイマーを回していくので
  var elapsedTime = 0;//タイマー経過をこの変数で保持
  var timetext = document.getElementById("js-timetext");
  var btnStart = document.getElementById("js-btn--start");
  var btnStop = document.getElementById("js-btn--stop");
  var btnReset = document.getElementById("js-btn--reset");
  function setBtnState (start, stop, reset){//ボタンの状態をture or falseで渡す
    btnStart.disabled = !start;//false startの否定
    btnStop.disabled = !stop;
    btnReset.disabled = !reset;
  setBtnState (true, false, false);
  btnStart.addEventListener("click", function(){
    startTime =;//1970年 1月1日 00:00:00 からの経過ミリ秒を取得
    setBtnState (false, true, false);//startをクリックしたらstopだけtrueにする

  btnStop.addEventListener("click", function(){
    elapsedTime += - startTime;//現在の時間から最初の時間を引いたものを足しあげる
    setBtnState (true, false, true);//stopをクリックしたらstop以外をtrueに
  btnReset.addEventListener("click" , function(){
    timetext.innerHTML = "0.00";//0.00に書き換える
    elapsedTime = 0;//0に書き換える
    setBtnState (true, false, false);//resetを押したら最初と同じ状態に

  function updateTimerText(){//updateTimerTextという関数を用意
    timerId = setTimeout(function(){
      var t = - startTime + elapsedTime;
      timetext.innerHTML = (t / 1000).toFixed(2);//ミリ秒を普通の秒になおすために1000で割る。toFixedは2ケタまで表示
    }, 10);//10ミリ秒間隔で実行