.. _dijit/byId: dijit.byId ========== :Status: Draft :Version: 1.0 :Project owner: Bill Keese :Available: since V0.9 .. contents:: :depth: 2 dijit.byId is a function for looking up a specific widget by its assigned name (id). This function is similar to :ref:`dojo.byId ` but whereas dojo.byId returns DOMNodes, dijit.byId returns a JavaScript object that is the instance of the widget. ============ Introduction ============ dijit.byId and dojo.byId are often confused, particularly by first time users. This function should be used when you wish to obtain a direct handle the the JavaScript object instance of your widget and access functions of that widget. ===== Usage ===== Usage of this function is trivial. Simply call it with a string of the id for the widget you wish to obtain the handle of. The return value will either be the JavaScript object instance that represents the widget or null/undefined if it is not found in the widget registry. .. code-block :: javascript :linenos: ======== Examples ======== Example 1: Locating a widget by its ID -------------------------------------- .. cv-compound :: .. cv :: javascript .. cv :: html

Example 2: Locating a widget by its id and accessing its DOM node (main DOM rendering element) ---------------------------------------------------------------------------------------------- .. cv-compound :: .. cv :: javascript .. cv :: html

Example 3: Comparing dojo.byId and dijit.byId --------------------------------------------- *This example shows how the output of each is different.* .. cv-compound :: .. cv :: javascript .. cv :: html

======== See also ======== * :ref:`dojo.byId `