function bindEvents() {
  let btnStart = document.querySelector('#btnStart');
  let btnStop = document.querySelector('#btnStop');
  let btnClear = document.querySelector('#btnClear');
  let stopwatch = document.querySelector('#stopwatch');

  // On Start button click, start the timer, disable the start button, and enable the stop & clear buttons
  btnStart.addEventListener('click', () => {
    stopwatchHandler(stopwatch, 'start');
    btnStart.setAttribute('disabled', 'true');
    btnStop.removeAttribute('disabled');
    btnClear.removeAttribute('disabled', 'true');
  });

  // On Stop button click, pause the timer, disable the stop button, and enable the start button
  btnStop.addEventListener('click', () => {
    stopwatchHandler(stopwatch, 'stop')
    btnStop.setAttribute('disabled', 'true');
    btnStart.removeAttribute('disabled');
  });

  // On Clear button click, reset the timer, disable the clear & stop buttons, and enable the start button
  btnClear.addEventListener('click', () => {
    stopwatchHandler(stopwatch, 'clear')
    btnStart.removeAttribute('disabled');
    btnStop.setAttribute('disabled', 'true');
    btnClear.setAttribute('disabled', 'true');
  });
}
// Binds event listeners to their respective buttons / elements
Binds event listeners to their respective buttons / elements
Binds event listeners to their respective buttons / elements
function bindEvents() {
  let btnStart = document.querySelector('#btnStart');
  let btnStop = document.querySelector('#btnStop');
  let btnClear = document.querySelector('#btnClear');
  let stopwatch = document.querySelector('#stopwatch');
  btnStart.addEventListener('click', () => {
    stopwatchHandler(stopwatch, 'start');
    btnStart.setAttribute('disabled', 'true');
    btnStop.removeAttribute('disabled');
    btnClear.removeAttribute('disabled', 'true');
  });
  btnStop.addEventListener('click', () => {
    stopwatchHandler(stopwatch, 'stop')
    btnStop.setAttribute('disabled', 'true');
    btnStart.removeAttribute('disabled');
  });
  btnClear.addEventListener('click', () => {
    stopwatchHandler(stopwatch, 'clear')
    btnStart.removeAttribute('disabled');
    btnStop.setAttribute('disabled', 'true');
    btnClear.setAttribute('disabled', 'true');
  });
}
function bindEvents ( ) { let btnStart = document . querySelector ( '#btnStart' ) ; let btnStop = document . querySelector ( '#btnStop' ) ; let btnClear = document . querySelector ( '#btnClear' ) ; let stopwatch = document . querySelector ( '#stopwatch' ) ; btnStart . addEventListener ( 'click' , ( ) => { stopwatchHandler ( stopwatch , 'start' ) ; btnStart . setAttribute ( 'disabled' , 'true' ) ; btnStop . removeAttribute ( 'disabled' ) ; btnClear . removeAttribute ( 'disabled' , 'true' ) ; } ) ; btnStop . addEventListener ( 'click' , ( ) => { stopwatchHandler ( stopwatch , 'stop' ) btnStop . setAttribute ( 'disabled' , 'true' ) ; btnStart . removeAttribute ( 'disabled' ) ; } ) ; btnClear . addEventListener ( 'click' , ( ) => { stopwatchHandler ( stopwatch , 'clear' ) btnStart . removeAttribute ( 'disabled' ) ; btnStop . setAttribute ( 'disabled' , 'true' ) ; btnClear . setAttribute ( 'disabled' , 'true' ) ; } ) ; }
Binds event listeners to their respective buttons / elements
Binds event listeners to their respective buttons / elements
// On Start button click, start the timer, disable the start button, and enable the stop & clear buttons // On Stop button click, pause the timer, disable the stop button, and enable the start button // On Clear button click, reset the timer, disable the clear & stop buttons, and enable the start button