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

为君一笑 提交于 2019-12-07 00:24:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!