Get the computed style properties for the first element in the set of matched elements or set one or more CSS properties for every matched element.
const color = $('p').css('color');
"rgb(0, 0, 0)"
$('.box').css('background-color', 'red');
<div class="box" style="background-color: red;"></div>
$('.box').css({
'width': 100,
'height': '100px',
'opacity': 0.5
});
<div class="box" style="width: 100px; height: 100px; opacity: 0.5;"></div>
| Parameter | Type | Description |
|---|---|---|
| prop | string | object | The name of the CSS property (camelCase or kebab-case), or an object of property-value pairs. |
| value | string | number | The value to set. Numbers are automatically converted to pixels for appropriate properties. |
Returns: The property value (string) for getter, or the original SR object for setter.