Skip to content

Instantly share code, notes, and snippets.

@justinswelch
Created October 3, 2019 21:01
Show Gist options
  • Save justinswelch/85d596e6e7d13aeeee7fc3cb6b09288e to your computer and use it in GitHub Desktop.
Save justinswelch/85d596e6e7d13aeeee7fc3cb6b09288e to your computer and use it in GitHub Desktop.
/**
* Remove inlined styles from target selector
* removeInlineStyles(targetSelector)
*
* @param {string} targetSelector (valid css selector)
* @return {null}
*/
const removeInlineStyles = function (targetSelector) {
try {
document.createDocumentFragment().querySelector(targetSelector)
}
catch (e) {
return console.warn(e);
}
window.onload = function () {
const target = document.querySelectorAll(`${targetSelector}`);
target.forEach((el) => { el.removeAttribute('style') });
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment