:star2: 3652 | @moigithub |http://www.freecodecamp.com/moigithub
hi could some one help me with this javascript syntax
var modal = document.querySelectorAll('.modal');
var currentModalValue;
var modalBtn = document.getElementsByClassName("modal-show");
var closeBtn = document.querySelector('.close-post');
function openModal(){
modal[currentModalValue].style.display = "block";
document.body.style.height ="100vh";
$('.modal').scrollTop(0);
}
function closeModal(){
modal[currentModalValue].style.display = "none";
}
for(var i=0;i<modalBtn.length;i++){
modalBtn[i].addEventListener('click', function(e){
currentModalValue = e.target.dataset.modal;
});
}
Please tell me how to pass the openModal function along with modalBtn[i].addEventListener() so that it runs when the button is pressed. Is this the right way to do it?