title: How to use same function for different IDs in Javascript using If statement
body: <p>I have to open different Modals based on the onClick event on IDs using same Function. I'm using If condition to check, but it is always taking the first condition to be true. Please help.</p>
  
  <pre><code>//html
  &lt;div id="Remote-Parking" class="element parking" onclick="modalFunction()"&gt;Remote-Parking&lt;/div&gt;
  &lt;div id="Emergency-Braking" class="element collision-detection" onclick="modalFunction()"&gt;Emergency-Braking&lt;/div&gt;
  
  
  //javascript
  function modalFunction() {
      if (document.getElementById('Emergency-Braking').onclick) {
          document.getElementById('Popup-Emergency-Braking').style.display="block";
      }
      if (document.getElementById('Remote-Parking').onclick) {
          document.getElementById('Popup-Remote-Parking').style.display="block";
      }
  }
  </code></pre>