Skip to content

Instantly share code, notes, and snippets.

@tinacious
Last active March 8, 2017 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tinacious/7c3e817391469550922a109f40410e26 to your computer and use it in GitHub Desktop.
Save tinacious/7c3e817391469550922a109f40410e26 to your computer and use it in GitHub Desktop.
Prompts the user for a width value in pixels and then finds all DOM elements greater than the provided width
/**
* Prompts the user for a width value in pixels and then
* finds all DOM elements greater than the provided width
*/
(function () {
const desiredWidth = Number(prompt('Wider than what? (px)'));
document.body.querySelectorAll('*')
.forEach((item) => {
var width = item.offsetWidth;
if (width > desiredWidth) console.log('Too big 🙅🏻', item);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment