Created
October 3, 2019 21:01
-
-
Save justinswelch/85d596e6e7d13aeeee7fc3cb6b09288e to your computer and use it in GitHub Desktop.
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
/** | |
* 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