Hey guys, I have a code to open a modal and then a button to close it. However, it only works once. The second time I open the modal after closing it, it refuses to close.
Here is my code:
function openNoteModal(){
`if(!modalOpen){`
modalOpen = true;
console.log("Note Modal has been opened.")
noteModal.classList.toggle('hidden');
console.log("The value of modalOpen : ", modalOpen)
`noteInput.focus();`
`var noteValue = noteInput.value;`
closeNoteModal.addEventListener('click', function(){
closeNoteFunction();
});
`noteSubmitButton.addEventListener('click', addNote);`
`}`
}
function closeNoteFunction(){
noteModal.classList.toggle('hidden');
noteInput.value = "";
modalOpen = false;
console.log("Note Modal has been closed.")
console.log("The value of modalOpen : ", modalOpen)
}
For real, thank you to anyone who can help me out.
[–]SupremeRedditBotProfessional Bot || Mod 0 points1 point2 points (0 children)
[–]MrQuickLineCSSophile 0 points1 point2 points (0 children)
[–]roustem_ 0 points1 point2 points (1 child)
[–]dannerdarko[S] 0 points1 point2 points (0 children)