0

Why is this returning null before returning the actual element?

const subNav = document.querySelector('.subnav-block');
console.log(subNav);

Here's the codepen, lines 30 and 31

Eric Nguyen
  • 926
  • 3
  • 15
  • 37

1 Answers1

1

The null is logged even before the dom is rendered, hence couldn't find the element.

Tejas H N
  • 11
  • 2