Skip to content

Instantly share code, notes, and snippets.

@ryanve
Last active September 17, 2016 21:07
Show Gist options
  • Select an option

  • Save ryanve/8156e99239477b6fb268aad5c0ec42cb to your computer and use it in GitHub Desktop.

Select an option

Save ryanve/8156e99239477b6fb268aad5c0ec42cb to your computer and use it in GitHub Desktop.
Compute and display an element's CSS properties
$('[data-compute]').each(function() {
$(this).text($(this.dataset.computeFrom).css(this.dataset.compute));
});
<b id="example">example element</b>
<ul>
<li>color: <code data-compute="color" data-compute-from="#example"></code>
<li>font-size: <code data-compute="font-size" data-compute-from="#example"></code>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment