Created
January 17, 2014 14:16
-
-
Save yukulele/8473973 to your computer and use it in GitHub Desktop.
jQuery Inline CSS remover
This file contains hidden or 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
jQuery.fn.removeInlineCss = function(property){ | |
if(property == null) | |
return this.removeAttr('style'); | |
var proporties = property.split(/\s+/); | |
return this.each(function(){ | |
var remover = | |
this.style.removeProperty // modern browsers | |
|| this.style.removeAttribute ; // old browsers (ie 6-8) | |
for(var i = 0 ; i < proporties.length ; i++) | |
remover.call(this.style,proporties[i]); | |
}); | |
}; |
This file contains hidden or 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 all inline styles | |
$(".foo").removeInlineCss(); | |
// remove one property | |
$(".foo").removeInlineCss("display"); | |
// remove several property | |
$(".foo").removeInlineCss("color font-size font-weight"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment