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
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.
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?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.