Answer the question
In order to leave comments, you need to log in
AddEventListener for Nodelist, how to hang a handler on each of the array elements?
It would be necessary that when you click on an element with the block class, the active class is removed or added, I don’t understand what needs to be passed to the function? Or is it not at all?
var blocks = document.querySelectorAll('.block');
[].forEach.call(blocks, function(/*Что здесь должно быть?*/) {
item.addEventListener('click', function() {
if (item.classList.contains('active')) {
item.classList.remove('active');
} else {
item.classList.add('active');
}
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question