I’m trying to make a list of functions so I can call one function to work onclick, not making a set of values to make it. I was trying to do it solely with functions. Is there a way to call the function instead of changing to a value?
Thank you for your comment. I now have posted the link containing the function. For a quick giveaway:
function na() {
// document.getElementById('open-modal').addEventListener('click', showModal);
// another event to click and close the modal.
document.getElementById('close-modal').addEventListener('click', hideModal);
// One function to show the modal
function showModal(){
// Grab the element class modal and show it by adding the style.
var modal = document.querySelector('.my-Modal');
modal.classList.add('show');
}
// Second function to close the modal.
function hideModal(){
// grab the element class modal and hide it by removing the style.
var modal = document.querySelector('.my-Modal');
modal.classList.remove('show');
}
}
function na2() {
// add an event listener on the click button
// document.getElementById('open-modal').addEventListener('click', showModal2);
// another event to click and close the modal.
document.getElementById('close-modal2').addEventListener('click', hideModal2);
// One function to show the modal
function showModal2(){
// Grab the element class modal and show it by adding the style.
var modal = document.querySelector('.my-Modal2');
modal.classList.add('show');
}
// Second function to close the modal.
function hideModal2(){
// grab the element class modal and hide it by removing the style.
var modal = document.querySelector('.my-Modal2');
modal.classList.remove('show');
}
}
function na3() {
// document.getElementById('open-modal').addEventListener('click', showModal2);
// another event to click and close the modal.
document.getElementById('close-modal3').addEventListener('click', hideModal);
// One function to show the modal
function showModal(){
// Grab the element class modal and show it by adding the style.
var modal = document.querySelector('.my-Modal3');
modal.classList.add('show');
}
// Second function to close the modal.
function hideModal(){
// grab the element class modal and hide it by removing the style.
var modal = document.querySelector('.my-Modal3');
modal.classList.remove('show');
}
}
function na4() {
// add an event listener on the click button
// document.getElementById('open-modal').addEventListener('click', showModal2);
// another event to click and close the modal.
document.getElementById('close-modal4').addEventListener('click', hideModal2);
// One function to show the modal
function showModal2(){
// Grab the element class modal and show it by adding the style.
var modal = document.querySelector('.my-Modal4');
modal.classList.add('show');
}
// Second function to close the modal.
function hideModal2(){
// grab the element class modal and hide it by removing the style.
var modal = document.querySelector('.my-Modal4');
modal.classList.remove('show');
}
}
@ILM,
They don’t indeed. I will try adding a return statement.
@DanCouper ,
I have given the code above explaining the functions; I will update when i change them.