This module defines the core dojo DOM style API.
See the dojo/dom-style reference documentation for more information.
Parameter | Type | Description |
---|---|---|
node | DOMNode | String | |
name | String | Object |
Returns a "computed style" object.
Gets a "computed style" object which can be used to gather information about the current state of the rendered node.
Note that this may behave differently on different browsers. Values may have different formats and value encodings across browsers.
Note also that this method is expensive. Wherever possible, reuse the returned object.
Use the dojo/dom-style.get() method for more consistent (pixelized) return values.
Parameter | Type | Description |
---|---|---|
node | DOMNode | A reference to a DOM node. Does NOT support taking an ID string for speed reasons. |
require(["dojo/dom-style", "dojo/dom"], function(domStyle, dom){ domStyle.getComputedStyle(dom.byId('foo')).borderWidth; });
Reusing the returned object, avoiding multiple lookups:
require(["dojo/dom-style", "dojo/dom"], function(domStyle, dom){ var cs = domStyle.getComputedStyle(dom.byId("someNode")); var w = cs.width, h = cs.height; });
Parameter | Type | Description |
---|---|---|
node | DOMNode | String | |
name | String | Object | |
value | String |
Optional
|
converts style value to pixels on IE or return a numeric value.
Parameter | Type | Description |
---|---|---|
node | DOMNode | |
value | String |