Can't find variable:document


#1

I am trying to access an XML element by simply typing “document.getElementById()” method but I get an error like “Can’t find variable document”.How can I solve this problem?


#2

document is something specific to browser, NativeScript doesn’t have a document api. But if you are interested in using apis like getElementById or class or name, you must install this plugin.


#3

Thanks for answer.Is there any way to install the plugin on online IDE?
tns plugin add nativescript-dom
I think I suppose to write this to the command but I’m using Nativescript Playground online.


#4

Yes, you can use the + icon besides the title Explorer in the left corner. You will be given a popup with a text field where you can enter the plugin name.


#5


Thanks again,but I couldn’t install the plugin.It gives a TypeError.What did I do wrong?


#6

Please read the instructions carefully, you supposed to enter just the plugin name and not the command itself.


#7

Completely forgot it! Thank you very much again!