Skip to content

Instantly share code, notes, and snippets.

@justxor
Created May 29, 2022 07:07
Show Gist options
  • Save justxor/9e1c5e585f4e8ed9e560847b745e4da8 to your computer and use it in GitHub Desktop.
Save justxor/9e1c5e585f4e8ed9e560847b745e4da8 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS getComputedStyle() Demo</title>
<style type="text/css">
.message {
background-color: #fff3d4;
border: solid 1px #f6b73c;
padding: 20px;
color: black;
}
</style>
</head>
<body>
<p class="message" style="color:red">
This is a JS getComputedStyle() Demo!
</p>
<script>
let message = document.querySelector('.message');
let style = getComputedStyle(message);
console.log('color:', style.color);
console.log('background color:', style.backgroundColor);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment