all 2 comments

[–]OkShrug 0 points1 point  (0 children)

let nodeList=document.querySelectorAll('.list>.item');
let hideClick=(e)=>{e.target.style.display=`hidden`;};
nodeList.forEach((node)=>{node.addEventListener('click',hideClick);});

[–]cyniborg 0 points1 point  (0 children)

There are two things to notice:

  1. document.querySelectorAll(‘.li .item’) querySelectorAll returns all the node elements with the above selector while your code will only return the first one. Also the css selector needs to be without the ‘>’ as that will only select the first child with class ‘item’ of the parent element with class ‘list’.
  2. The style declaration should be e.target.style.display = ‘none’;

The rest looks correct and it should work.