title: Get number value from HTML element using JavaScript
body: <p>How can I get a number value from inside the HTML element, which I would later use in the countdown? I keep getting error that document.getElementById(...) is null, am I missing something with concatenation? Here's the fiddle: <a href="https://jsfiddle.net/L6ddLc0L/" rel="nofollow">https://jsfiddle.net/L6ddLc0L/</a></p>
  
  <pre><code>&lt;h1 id="num"&gt;50&lt;/h1&gt;
  
  &lt;div id="status"&gt;&lt;/div&gt;
  
  &lt;button onclick='countDown(secs, "status")'&gt;Start countdown&lt;/button&gt;
  &lt;button onclick='increaseNumber()'&gt;Increase&lt;/button&gt;
  
  
  var num = document.getElementById('num').innerHTML;
  var secs = num.parseInt();
  
  function increaseNumber() {
      secs++;
  }
  
  function countDown(secs, elem) {
      var element = document.getElementById(elem); //(elem)
      element.innerHTML = "Please wait for "+secs+" seconds";
      //if timer goes into negative numbers
      if(secs &lt; 1){
          clearTimeout(timer);
          element.innerHTML = '&lt;h2&gt;Countdown complete!&lt;/h2&gt;';
          element.innerHTML += '&lt;a href="#"&gt;Click here now&lt;/a&gt;';
      }
  
      secs--;
      var timer = setTimeout('countDown('+secs+', "'+elem+'")',1000);
  }
  </code></pre>