title: Run a javascript script when a button click is not working
body: <p>I have a script as following.</p>
  
  <pre><code>var time = document.getElementById("picker-dates").value;
  time = time.split(':');
  var date = new Date();
  var countDownDate = date.setHours(time[0], time[1], time[2]);
  
  function countdownTimeStart() {
  var x = setInterval(function () {
  
      // set hours, minutes and seconds, decrease seconds
      var hours = time[0];
      var minutes = time[1];
      var seconds = time[2]--;
  
      // if seconds are negative, set them to 59 and reduce minutes
      if (time[2] == -1) {
          time[1]--;
          time[2] = 59
      }
  
      // if minutes are negative, set them to 59 and reduce hours
      if (time[1] == -1) {
          time[0]--;
          time[1] = 59
      }
  
      // Output the result in an element with id="demo"
      // add leading zero for seconds if seconds lower than 10
      if (seconds &lt; 10) {
          document.getElementById("demo").innerHTML = hours + ": " + minutes + ": " + "0" + seconds + " ";
      } else {
          document.getElementById("demo").innerHTML = hours + ": " + minutes + ": " + seconds + " ";
      }
  
  
      // If the count down is over, write some text
      if (distance &lt; 0) {
          clearInterval(x);
          document.getElementById("demo").innerHTML = "00:00:00";
      }
  }, 1000);}
   countdownTimeStart();
  </code></pre>
  
  <p>So I want to run this script when a button click. I tried it as</p>
  
  <pre><code>&lt;button class="start" onclick="countdownTimeStart();"&gt;Start&lt;/button&gt;
  </code></pre>
  
  <p>But this is not working. How can I get this to work. Can someone help me to solve this.</p>