Last active
August 29, 2015 14:23
-
-
Save robinweser/464aaaa4ae56499d8d82 to your computer and use it in GitHub Desktop.
element selector to get all elements with a given style property value
This file contains 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
/* | |
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