Skip to content

Instantly share code, notes, and snippets.

@nileshbhagwat
Last active February 28, 2020 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nileshbhagwat/c58f696e18dbfa1bbe412c1a054f1c4b to your computer and use it in GitHub Desktop.
Save nileshbhagwat/c58f696e18dbfa1bbe412c1a054f1c4b to your computer and use it in GitHub Desktop.
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.
const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName];
@nileshbhagwat
Copy link
Author

e.g: getStyle(document.querySelector('p'), 'font-size'); // '14px'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment