0

This is seriously weird and it's making me crazy...

When I check the properties of the datalist, it clearly has a list property, but I still can't access it.

What am I doing wrong? This is impossible.

let datalistElement = document.getElementById("some-id");

console.dir(datalistElement);             // Shows the element
console.log(datalistElement.list);        // null
Ivan
  • 1,967
  • 4
  • 34
  • 60
  • 2
    Would you mind providing a reproducible example? There is not currently enough information in the question for us to help. – Unmitigated Jul 11 '20 at 03:50

2 Answers2

0

I realized I'm an idiot. I am setting the datalist options via an API request, and I am trying to access them before being set... I need a rest.

Ivan
  • 1,967
  • 4
  • 34
  • 60
0

console.log and console.dir behaves little different with browsers. Refer this.

Have you tried console.dir(JSON.stringify(datalistElement));.

Do you still see list property in strirngified value?

Prathap Reddy
  • 1,688
  • 2
  • 6
  • 18