Created
July 26, 2019 18:55
-
-
Save panphora/44ce3a407caffe0a347c4cbb3b7e5849 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var elem = document.querySelector("body"); | |
| function deepForEachElem (elem, callback) { | |
| callback(elem); | |
| Array.from(elem.children || []).forEach(function (el) { | |
| deepForEachElem(el, callback); | |
| }); | |
| } | |
| deepForEachElem(elem, function (el) { | |
| let width = el.getBoundingClientRect().width; | |
| console.log(width, el); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment