I have a button which opens a popup when clicked, and in this popup there is a close button to close the popup but that close button is not working!
Here is my code:
var fromToDate = document.getElementById('from-to-date');
var openFromToDate = document.getElementById('open-from-to-date');
var closeFromToDate = document.getElementById('close-from-to-date');
openFromToDate.addEventListener('click', function() {
fromToDate.classList.remove('dis-none');
});
closeFromToDate.addEventListener('click', function() {
fromToDate.classList.add('dis-none');
});
.dis-none {
display: none;
}
/* To make the button visible here */
.fa-times::after {
content: 'X';
}
<li id="open-from-to-date">
<span class="custom-span-style warning-bk date-span">
From: 2022-09-16 To: 2022-09-18
</span>
<div class="from-to-date dis-none" id="from-to-date">
<div class="from-to-date-wrapper">
<div class="close-from-to-date" id="close-from-to-date">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
</div>
</div>
</li>