Skip to content

Instantly share code, notes, and snippets.

@robinweser
Last active August 29, 2015 14:23
Show Gist options
  • Save robinweser/464aaaa4ae56499d8d82 to your computer and use it in GitHub Desktop.
Save robinweser/464aaaa4ae56499d8d82 to your computer and use it in GitHub Desktop.
element selector to get all elements with a given style property value
/*
Warning: This way is for sure not performant
*/
document.getElementsByStyleProperty = function(property, value){
var allBodyElements = document.body.querySelectorAll("*");
var selectedElements = [];
var allBodyElementsLength = allBodyElements.length;
for (var i = 0; i < allBodyElementsLength; ++i) {
if (Extend.getStyleProperty(allBodyElements[i], property) == value) {
selectedElements.push(allBodyElements[i]);
}
}
return selectedElements;
}
/*
document.getElementsByStyleProperty('font-size', '15px') => all elements with an 15px font size
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment