.getStyle(...properties?)
Available on: InDom

Gets computed CSS value(s) for the underlying element.

Parameters:
...properties {string} [optional] - Zero or more CSS property names (dash-case).

Returns: {CSSStyleDeclaration | string | Object} -
Full CSSStyleDeclaration when no arguments supplied.
Computed value as string when exactly one property supplied.
Object map { prop: value } when two or more properties supplied.

Throws:
Error - If the underlying element has been removed

Examples:
const div = $n('
'
); $1('body').append(div); // single property div.setStyle('background-color', 'blue'); console.log(div.getStyle('background-color')); // rgb(0, 0, 255) // bulk assignment + multi-read div.setStyle({ width: '100px', height: '50px', fontSize: '16px' }); console.log(div.getStyle('width', 'height', 'font-size')); // {width: '100px', height: '50px', 'font-size': '16px'} // apply to collection $a('.example>div').setStyle({ color: 'blue', 'font-size': '15px' }); // inspect every computed property const styles = $1('.example>div').getStyle(); console.log([styles.color, styles.fontSize]); // ['rgb(0, 0, 255)', '15px']
Modern DOM Power
for TypeScript, ESM & Plain JS
3.8KB JavaScript library that simplifies DOM manipulation
with a clean, chainable API for events, data, inputs harvesting, and more.
Automatic Cleanup,
Leak-Proof by Design
Events and state are cleared when elements leave the DOM,
even if removal happens outside InDom.
Cleaner Code,
Better Ergonomics
Get the InDom object directly in callbacks.
One element, one instance.
Works With Your Existing Stack
Use InDom on its own or alongside any library or framework,
its architecture ensures a seamless integration.