问题
Each time am trying the get the value of an element in my page, I have an error as is undefined: I have tried dijit.byId('myid').innerHTML('loading...');
I get an error
but when i do the same using jquery, it works $('#myid').html('loading ...')
And what is the equivalent of this $('#myid').html()
in dojo?
Thanks for any advise
回答1:
dijit.byId
returns a dijit object by some id.
dojo.byId
is the equivalent of $()
. To get/set it's HTML, use
dojo.byId("my_id").innerHTML
dojo.byId("my_id").innerHTML = some_text`
Note that dojo.byId
is just a wrapper around document.getElementById
, so you can use all the basic functions.
回答2:
dijit.byId("my_id") ----> returns the widget associated with the domNode.
dojo.byId("my_id") -----> returns the domNode itself.
To access the domNode using dijit:
dijit.byId("my_id").domNode.innerHTML
来源:https://stackoverflow.com/questions/4159113/what-the-difference-between-dojo-byid-and-dijit-byid