W3cubDocs

/Dojo

dojo/dom-style

Summary

This module defines the core dojo DOM style API.

See the dojo/dom-style reference documentation for more information.

Methods

get(node,name)

Defined by dojox/html/ext-dojo/style

Parameter Type Description
node DOMNode | String
name String | Object

Returns: undefined

getComputedStyle(node)

Defined by dojo/dom-style

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.

Examples

Example 1

require(["dojo/dom-style", "dojo/dom"], function(domStyle, dom){
    domStyle.getComputedStyle(dom.byId('foo')).borderWidth;
});

Example 2

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;
});

set(node,name,value)

Defined by dojox/html/ext-dojo/style

Parameter Type Description
node DOMNode | String
name String | Object
value String
Optional

Returns: undefined | instance

toPixelValue(node,value)

Defined by dojo/dom-style

converts style value to pixels on IE or return a numeric value.

Parameter Type Description
node DOMNode
value String

Returns: Number

© 2005–2017 JS Foundation
Licensed under the AFL 2.1 and BSD 3-Clause licenses.
http://dojotoolkit.org/api/1.10/dojo/dom-style.html