Files
30-seconds-of-code/snippets/getStyle.md
2017-12-28 22:38:33 +00:00

14 lines
317 B
Markdown

### getStyle
Returns the value of a CSS rule for the specified element.
Use `Window.getComputedStyle()` to get the value of the CSS rule for the specified element.
```js
const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName];
```
```js
getStyle(document.querySelector('p'), 'font-size'); // '16px'
```