I have a page that needs to have different modal boxes open when their corresponding link on the page is clicked. I\'ve got the structure and javascript to work for ONE wind
You must make modals unique to be able to select them later. One way to do this is through id
.
You need to define which button which window should open. One possible solution for this is through data-attributes
//will open modal one
//will open modal two
And then - event:
var btn = document.getElementsByClassName("click-to-open");
for (var i = 0; i < btn.length; i++) {
var thisBtn = btn[i];
thisBtn.addEventListener("click", function(){
var modal = document.getElementById(this.dataset.modal);
modal.style.display = "block";
}, false);
Again - this is one possible solution.