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.
//html
<div id="Remote-Parking" class="element parking"
onclick="modalFunction()">
<div id="Emergency-Braking" class="element collision-detection" onclick="modalFunction()">
//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";
}
}
Aucun commentaire:
Enregistrer un commentaire