This module defines the core dojo DOM API.
See the dojo/dom reference documentation for more information.
Returns DOM node with matching id
attribute or falsy value (ex: null or undefined)
if not found. If id
is a DomNode, this function is a no-op.
Parameter | Type | Description |
---|---|---|
id | String | DOMNode | A string to match an HTML id attribute or a reference to a DOM Node |
doc | Document |
Optional Document to work in. Defaults to the current value of dojo/_base/window.doc. Can be used to retrieve node references from other documents. |
Look up a node by ID:
require(["dojo/dom"], function(dom){ var n = dom.byId("foo"); });
Check if a node exists, and use it.
require(["dojo/dom"], function(dom){ var n = dom.byId("bar"); if(n){ doStuff() ... } });
Allow string or DomNode references to be passed to a custom function:
require(["dojo/dom"], function(dom){ var foo = function(nodeOrId){ nodeOrId = dom.byId(nodeOrId); // ... more stuff } });
Returns true if node is a descendant of ancestor
Parameter | Type | Description |
---|---|---|
node | DOMNode | String | string id or node reference to test |
ancestor | DOMNode | String | string id or node reference of potential parent to test against |
Test is node id="bar" is a descendant of node id="foo"
require(["dojo/dom"], function(dom){ if(dom.isDescendant("bar", "foo")){ ... } });
Parameter | Type | Description |
---|---|---|
node | undefined | |
selectable | undefined |