title: How to check if button was Pressed javaScript
body: <p>I have this button in HTML and I need to check if the button has been pressed to activate another function or not.</p>
  <pre><code>&lt;button id=&quot;generator&quot; class=&quot;button ripple&quot; onclick=&quot;myFunction()&quot;&gt;Berechnen&lt;/button&gt;
  </code></pre>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    function printDiv(print) {
          if(document.getElementById('generator').clicked == true){
              var printContents = document.getElementById(print).innerHTML;
              var originalContents = document.body.innerHTML;
         
              document.body.innerHTML = printContents;   
              window.print();
              document.body.innerHTML = originalContents;
              
          }
          else{
              alert("pls select")
          }
         
     }</code></pre>
  </div>
  </div>
  </p>