Answer the question
In order to leave comments, you need to log in
I can not understand and parse the code, help?
const spans = document.querySelectorAll('span');
for(let span of spans){
span.addEventListener('click', function(e){
e.target.parentNode.removeChild(e.target);
})
}
Answer the question
In order to leave comments, you need to log in
const - constant, immutable variable. In this case, this is a whim of the author of the
e - event object, it contains information about the event and the element on which it worked
. for..of
Deletes itself, since we find the parent from the current element (.parentNode) and delete the child from this parent, that is yourself (e.target)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question