I have multiple buttons having same element id, But when I click on first button, the pop-up is coming. If I click on any other buttons pop-up will not come. How can I make it possible.
<form method="post" action="trial.php">
<!-- Trigger/Open The Modal -->
<input type="button" id="myBtn" value="assign"></input>
<input type="button" id="myBtn" value="asd"></input>
<input type="button" id="myBtn" value="assign"></input>
<input type="button" id="myBtn" value="assign"></input>
<input type="button" id="myBtn" value="assign"></input>
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close">×</span>
<p>Assign Project</p>
<hr style="height:0.25px; background:black;"></hr>
<div class="container">
<div class="row">
<p class="col-md-10"><br/>Assign Project to a Existing Team :
<a class="btn btn-primary" id="ExistingTeam" value="Existing Team" href="google.com">Existing Team</a></p>
</div>
<div class="row">
<p class="col-md-10"><br/>Create a new Team and Assign Project :
<a class="btn btn-primary" id="CreateTeam" value="Create Team" href="google.com">Create Team</a></p>
</div>
</div>
</div>
</div>
</form>
These is the javascript I am using for pop-up
<script>
// Get the modal
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>