What is the difference between dojo.byId and dijit.byId?

Every time I try to get the value of an element on my page, I have an error as it is undefined: I tried dijit.byId('myid').innerHTML('loading...');

I get an error but when I do the same with jquery it works $('#myid').html('loading ...')

And what is equivalent to this $('#myid').html() in dojo? Thanks for any advice.

+6
javascript dojo
source share
2 answers

dijit.byId returns a dijit object with some id.

dojo.byId is the equivalent of $() . To get / set it in 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.

+7
source share
 dijit.byId("my_id") ----> returns the widget associated with the domNode. dojo.byId("my_id") -----> returns the domNode itself. 

To access domNode using dijit:

 dijit.byId("my_id").domNode.innerHTML 
+2
source share

All Articles