Skip to content

Instantly share code, notes, and snippets.

@rlemon
Last active May 11, 2016 15:34
Show Gist options
  • Save rlemon/4706993 to your computer and use it in GitHub Desktop.
Save rlemon/4706993 to your computer and use it in GitHub Desktop.
jquery css without jquery
Element.prototype.css = function (a, b) {
var style = function(t,k) {
return window.getComputedStyle(t)[k];
};
if (typeof b === "undefined") {
if (typeof a === "string") {
return style(this,a);
} else if (Array.isArray(a)) {
return a.map(function(s) {
return style(this,s);
});
} else {
for (var k in a) {
this.style[k] = a[k];
}
}
} else {
this.style[a] = b;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment