Get The CSS Value Of A Property In Java Script

Fetch your CSS values within your JavaScript code

CSS styles in JavaScript

Fetching CSS styles in JavaScript is quite easy, we need to use the getComputedStyle() global function.

const element = document.querySelector(".element");
const style = getComputedStyle(element);
style.color; // the value of the color