Skip to content

Instantly share code, notes, and snippets.

@donquixote
Last active December 13, 2019 01:59
Show Gist options
  • Save donquixote/f228ad928f00cb465230e47be30bd146 to your computer and use it in GitHub Desktop.
Save donquixote/f228ad928f00cb465230e47be30bd146 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<style>
div {
--varname: '5';
unknown_property: '5';
content: 'hello';
float: left;
}
</style>
<script>
var div = document.getElementsByTagName('div')[0];
var style = window.getComputedStyle(div);
var keys = ['--varname', 'unknown_property', 'content', 'float'];
var values = {};
for (var i in keys) {
k = keys[i];
values[k] = style.getPropertyValue(k);
}
console.log(values);
div.innerHTML = JSON.stringify(values);
</script>
</head>
<body>
<div>hello w</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment