0
<ul class="gallery"></ul>

and

     const images = [
  {
    url:  ,
    alt:  ,
  },

document.body.style.backgroundColor = "#0009";
const imageGalleryItem = document.querySelector("ul >li");
imageGalleryItem.forEach(element => {'ul.style.listStyleType = none;'})

There is the problem: Cannot read properties of null (reading 'forEach'). Hello, can You help how to fix it?

  • The two main problems I see are: (1) `ul >li` doesn't match any element in the markup, so `querySelector` won't return anything. (2) `querySelector` returns a single element and you're expecting it to return a list of elements. – David Mar 12 '23 at 12:24

1 Answers1

0

It means that imageGalleryItem is null because selector expression is incorrect. If you want to select all ul elements that are direct children of li element, then you should use document.querySelectorAll("li > ul").

Here is how to fix it (assuming you select all ul elements, not only children of li):

document.body.style.backgroundColor = "#0009";
const imageGalleryItem = document.querySelectorAll("ul");

imageGalleryItem.forEach(element => {element.style.listStyleType = "none";})
llesha
  • 423
  • 1
  • 15