title: Button click event binding in Electron js
body: <p>I have started using electron js to develop desktop application.</p>
  
  <p>I want to know that how to bind button click event with javascript function so that I can perform other operation.</p>
  
  <p>I used below HTML code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Manav Finance&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;input type="button" onclick="getData()" value="Get Data" /&gt;
    &lt;/body&gt;
  
    &lt;script&gt;
      // You can also require other files to run in this process
      require('./renderer.js')
    &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My renderer.js code looks like this:</p>
  
  <pre><code>function getData(){
          console.log('Called!!!');
      }
  </code></pre>
  
  <p>But I am getting error that:</p>
  
  <blockquote>
    <p>Uncaught ReferenceError: getData is not defined
        at HTMLInputElement.onclick</p>
  </blockquote>
  
  <p>Am I doing something wrong?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Updated HTML document and removed require() method and its working now:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Manav Finance&lt;/title&gt;
      &lt;script src="renderer.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;input type="button" id="btnEd" value="Get Data" onclick="getData()" /&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>