I'm getting null
when trying to find <body>
element with querySelector()
on document
object after compiling to javascript. Here's the Dart code:
void main() {
print(document.querySelector('body')); // => null
}
This also produces a range error:
document.getElementsByTagName('body')[0] // => Range error, obviously the List is empty
The dart code works just fine in Dartium though.
Figured it out. I included the script in the <head>
section, and should've done it after all the contents inside <body>
.
Weird, but you don't need querySelector()
for the body
element. Just use document.body
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.