title: Get particular Button click event using IPC
body: <p>I am using electron IPC to communicate and capture events from the guest content of webview.(Please refer this <a href="https://ourcodeworld.com/articles/read/201/how-to-send-retrieve-information-and-manipulate-the-dom-from-a-webview-with-electron-framework" rel="nofollow noreferrer">link</a> for more details about code)</p>
  
  <pre><code>&lt;webview id="myView" src="http://127.0.0.1:8080" nodeintegration preload="./inyector.js"&gt;&lt;/webview&gt;
  </code></pre>
  
  <p>In the inyector.js file, i have used below code to capture every click event:</p>
  
  <pre><code>document.addEventListener('click', function(event) {
      ipcRenderer.sendToHost(event);
  });
  </code></pre>
  
  <p>The above code will trigger for every click on the page but what i want is to capture a particular button click with some id also want to pass info from that button to my host page.</p>
  
  <p>i have already tried below code but its not working:</p>
  
  <pre><code>var btn = document.getElementById("mybtn");
  
  btn.addEventListener('click', function (event) {
     ipcRenderer.sendToHost(event);
  });
  </code></pre>
  
  <p>Any help would be appreciated. Thanks </p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>i am able to solve the above problem. Instead of using preload file, i have added the IPC in my guest application and use the same code of preload script  to send event from rendered process to main process.</p>