Created
September 2, 2019 04:41
-
-
Save karlcow/ef42b4617e2cc4a15d62b62d47fe7112 to your computer and use it in GitHub Desktop.
Iterate through the DOM to search element wider than a certain width.
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
// Iterate through the DOM to search element wider than a certain width. | |
// Practical for issues with invisible blocks creating layout issues | |
// on mobile. | |
// set here the maxwidth of your choice. | |
var maxwidth = 414; | |
var startElem = document.getElementsByTagName('body')[0]; | |
var items = startElem.getElementsByTagName("*"); | |
for (var i = items.length; i--;) { | |
if (items[i].getBoundingClientRect()['width'] > maxwidth) { | |
console.log(items[i], items[i].getBoundingClientRect()['width']) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment