dojo.byId and dijit.byId
dojo.byId(String id)This function is a synonym for document.all.id in IE or document.getElementById(id) in standard DOM. So you can say:
dojo.
byId
(
"breadbox"
).
style.
fontSize =
"72pt";
If document.getElementById() works in all modern browsers,why use this? Sadly,bugs persist in Internet Explorer which make getElementById() unstable in some common scenarios. Also,dojo.byId() is easier to type. dijit.byId(String id)Because of the almost-identical spelling,this method is commonly mixed up with dojo.byId(String id). Here's the difference: dijit.byId() returns a Dijit widget instance - technically,an instance of dijit._Widget or one of its subclasses like dijit.Toolbar or dijit.TreeNode. So here's the way to remember it:
Or for you who think in terms of functions (e.g. LISP programmers?): var myDomNode = dojo.byId("foo"); var myWidget = dijit.byId("foo"); console.debug(myDomNode == myWidget.domNode); // true console.debug(dijit.byNode(myDomNode) == myWidget); // true (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |