Skip to content

Instantly share code, notes, and snippets.

@Nick-Gabe
Created June 23, 2022 23:52
Show Gist options
  • Save Nick-Gabe/269a4f70b6b7c8f8bb27eda3e7c3aa48 to your computer and use it in GitHub Desktop.
Save Nick-Gabe/269a4f70b6b7c8f8bb27eda3e7c3aa48 to your computer and use it in GitHub Desktop.
Adds styles to a Html Element based on a CSS Object.
interface HTMLElement {
setStyle(newStyles: Partial<CSSStyleDeclaration>): void;
}
HTMLElement.prototype.setStyle = function (newStyles) {
for (let style in newStyles) {
this.style[style] = newStyles[style]!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment