the read element was appended to another div container element by the submit eventlistener. but I can't access the read element when trying to attach it to another event listener outside the function. Any idea how to fix this?
function add() {
read = document.createElement('div');
read.textContent = 'Read';
read.classList.add('read');
card.appendChild(read);
}
submit.addEventListener('click', add);
read.addEventListener("click", () => {
read.classList.toggle('unread');
});