See the dojo/dom-prop reference documentation for more information.
Defined by: dojo/dom-prop
get
(node,name)
Defined by dojo/dom-prop
Gets a property on an HTML element.
Handles normalized getting of properties on DOM nodes.
Parameter | Type | Description |
---|---|---|
node | DOMNode | String |
id or reference to the element to get the property on |
name | String |
the name of the property to get. |
Returns: any | undefined
the value of the requested property or its default value
// get the current value of the "foo" property on a node
require(["dojo/dom-prop", "dojo/dom"], function(domProp, dom){
domProp.get(dom.byId("nodeId"), "foo");
// or we can just pass the id:
domProp.get("nodeId", "foo");
});
set
(node,name,value)
Defined by dojo/dom-prop
Sets a property on an HTML element.
Handles normalized setting of properties on DOM nodes.
When passing functions as values, note that they will not be directly assigned to slots on the node, but rather the default behavior will be removed and the new behavior will be added using dojo.connect()
, meaning that event handler properties will be normalized and that some caveats with regards to non-standard behaviors for onsubmit apply. Namely that you should cancel form submission using dojo.stopEvent()
on the passed event object instead of returning a boolean value from the handler itself.
Parameter | Type | Description |
---|---|---|
node | DOMNode | String |
id or reference to the element to set the property on |
name | String | Object |
the name of the property to set, or a hash object to set multiple properties at once. |
value | String | Optional
The value to set for the property |
Returns: any | undefined
the DOM node
// use prop() to set the tab index
require(["dojo/dom-prop"], function(domProp){
domProp.set("nodeId", "tabIndex", 3);
});
Set multiple values at once, including event handlers:
require(["dojo/dom-prop"], function(domProp){
domProp.set("formId", {
"foo": "bar",
"tabIndex": -1,
"method": "POST",
});
});
© 2005–2017 JS Foundation
Licensed under the AFL 2.1 and BSD 3-Clause licenses.
http://dojotoolkit.org/api/1.10/dojo/dom-prop.html