.setStyle(propertyOrMap, value?)
Available on: InDom, InDomArraySets one or more CSS properties to the underlying element(s). Dash-case names are auto-converted to camel-case.Parameters:
propertyOrMap {string} - Property name (dash-case or camel-case) or object map { prop: value, ... } for bulk assignment
value {string} - Value to assign (when first arg is a string)
Returns: {InDom | InDomArray} - this for chaining Throws: Error - If the underlying element(s) has been removed
TypeError - If a single argument is not an object
Examples:const div = $n('<div></div>');
$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']Next: getStyle »