When targeting class names in an HTML page with a checkbox using querySelectorAll, keep in mind that getElementByID only works with the first element. QuerySelectorAll displays a nodeList which might require some corrections - how can this be achieved?
let salesCheckbox = document.getElementById('sales-checkbox');
let euroSalesCurrency = document.querySelectorAll('.euro-sales-currency');
let originalSalesCurrency = document.querySelectorAll('.original-sales-currency');
if (salesCheckbox) {
salesCheckbox.addEventListener('click', saleCheckbox);
}
//Function to close thirty
function saleCheckbox() {
euroSalesCurrency.style.display = 'none';
originalSalesCurrency.style.display = "block";
}
I am looking to show a span element when the user checks the checkbox and hide it when unchecked.