I am working on implementing a click event for a checkbox that will add and remove CSS classes using the "classList.toggle" method. Specifically, I want the checkbox to toggle between adding the "xyz" class on the first click, and then adding the "abc" class while removing the "xyz" class on the second click.
const openModal = document.getElementById('mark-as-gift');
const modalBg = document.querySelector('.addtnew');
openModal.addEventListener('click', openModalBtn);
function openModalBtn() {
modalBg.classList.add('menscart2');
}
That's where I currently stand with my JavaScript code. Any assistance would be greatly appreciated!