Skip to content

Instantly share code, notes, and snippets.

View darbicus's full-sized avatar

Darby Rathbone darbicus

  • Texas
View GitHub Profile
@darbicus
darbicus / getElementCssStyleRules.js
Created September 4, 2014 21:45
getElementCssStyleRules is a function to return an array of the css rules that affect the element supplied to the function...
var getElementCSSStyleRules = function (f) {
var myElement = f;
var r = [];
[].slice.call(document.styleSheets).forEach(function (rules) {
[].slice.call(rules.rules).forEach(function (e) {
if ([].slice.call(document.querySelectorAll(e.selectorText)).indexOf(f) !== -1) {
e.toString = function(){return this.selectorText;};
r.push(e);
}